Compare commits

..

15 Commits

  1. 19
      Dockerfile
  2. 91
      bin/api.js
  3. 99
      bin/cli.js
  4. 8
      build/_build.ts
  5. 282
      build/_deploy.ts
  6. 975
      build/dns-auto-code.cell.fif
  7. 972
      build/dns-auto-code.fif
  8. 208
      build/dns-utils.cell.fif
  9. 205
      build/dns-utils.fif
  10. 1
      build/main.compiled.json
  11. 1191
      build/main.fif
  12. 1
      build/nft-collection.compiled.json
  13. 11
      build/nft-collection.deploy.ts
  14. 845
      build/nft-collection.fif
  15. 1
      build/nft-item.compiled.json
  16. 944
      build/nft-item.fif
  17. 1
      build/wrapper.compiled.json
  18. 136
      build/wrapper.fif
  19. 90
      contracts/imports/dns-utils.fc
  20. 1
      contracts/imports/op-codes.fc
  21. 345
      contracts/main.ts
  22. 95
      contracts/nft-collection.fc
  23. 110
      contracts/nft-item.fc
  24. 165
      contracts/utils.ts
  25. 1501
      package-lock.json
  26. 14
      package.json
  27. 19
      test/creation.spec.ts
  28. 71
      test/item.spec.ts
  29. 56
      test/selling.spec.ts
  30. 71
      test/signing.spec.ts

19
Dockerfile

@ -0,0 +1,19 @@
FROM node:latest
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 5171
CMD [ "npm", "run", "api" ]

91
bin/api.js

@ -0,0 +1,91 @@
const main = require("../contracts/main");
const { Address, Cell, Slice } = require("ton");
const { Base64 } = require("@tonconnect/protocol");
require("dotenv").config();
const express = require("express");
const { get_tonclient, AdnlAddress } = require("../contracts/utils");
const { getRecords } = require("../contracts/main");
const { sha256 } = require("ton-crypto");
const { BN } = require("bn.js");
const app = express();
const port = 5171;
const debug = process.env.DEBUG === "1";
let tonclient = get_tonclient(debug);
app.use(function (err, req, res, next) {
if (!err) return next(); // you also need this line
console.log("error");
res.send("error");
});
app.get("/", async (req, res) => {
res.send("Agorata microservice for dealing with TON");
});
app.get("/buy-message/:collection/:domain" /* the rest as get parameters: buyer, key */, (req, res) => {
try {
let collection = Address.parse(req.params.collection);
if (req.query.buyer !== "") {
let buyer = Address.parse(req.query.buyer);
let key = Buffer.from(req.query.key, "hex");
let signature = main.signBuy(req.params.domain, collection, buyer, key);
let msg = main.createItem({ domain: req.params.domain, signature });
res.send(JSON.stringify([Base64.encode(msg.toBoc()), collection.toString()]));
} else {
let msg = main.createItem({ domain: req.params.domain, signature: "0" });
res.send(JSON.stringify([Base64.encode(msg.toBoc()), collection.toString()]));
}
} catch (e) {
console.error("buy-message", e);
}
});
app.get("/content-message/:address/:zone/:domain", async (req, res) => {
try {
let msg = await main.setContent({ domain: req.params.domain, zone: req.params.zone });
let addr = main.getItemAddr(Address.parse(req.params.address), req.params.domain, 0);
res.send(JSON.stringify([Base64.encode(msg.toBoc()), addr.toString()]));
} catch (e) {
console.error("content-message");
}
});
app.get("/address/:collection/:domain", (req, res) => {
let addr = main.getItemAddr(Address.parse(req.params.collection), req.params.domain, 0);
res.send(JSON.stringify({ address: addr.toString() }));
});
app.get("/get-records/:address", async (req, res) => {
try {
let records = await getRecords(tonclient, Address.parse(req.params.address));
// console.log(records)
res.send(JSON.stringify(records));
} catch (e) {
console.log(e);
res.send(JSON.stringify({}));
}
});
app.get("/get-price/:address/:subdomain", async (req, res) => {
let price = await main.getPrice(tonclient, Address.parse(req.params.address), req.params.subdomain);
res.send(JSON.stringify(price));
});
app.get("/set-record/site/:site", async (req, res) => {
let site = new AdnlAddress(req.params.site);
let msg = await main.changeRecordMsg("site", await main.AdnlRecord(site));
res.send(JSON.stringify(Base64.encode(msg.toBoc())));
});
app.get("/hash/:key", async (req, res) => {
res.send(new BN(await sha256(req.params.key)).toString());
});
app.get("/set-record/wallet/:wallet", async (req, res) => {
let wallet = Address.parse(req.params.wallet);
let msg = await main.changeRecordMsg("wallet", await main.WalletRecord(wallet));
res.send(JSON.stringify(Base64.encode(msg.toBoc())));
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});

99
bin/cli.js

@ -0,0 +1,99 @@
const main = require('../contracts/main');
const subcommand = require('subcommand');
const {Address} = require("ton");
const {keyPairFromSeed, getSecureRandomBytes, keyPairFromSecretKey} = require("ton-crypto");
const {Base64} = require('@tonconnect/protocol');
const BN = require("bn.js");
const argv = process.argv.slice(2);
let commands = [
{
name: 'buy-message',
options: [ // cliclopts options
// {
// name: 'loud',
// boolean: true,
// default: false,
// abbr: 'v',
// help: 'print out all output loudly'
// }
{
name: 'domain'
},
{
name: 'collection'
},
{
name: 'buyer',
help: 'Buyer\'s address'
},
{
name: 'key',
help: 'Secret key, hex-encoded'
}
],
command: function message(args) {
let collection = Address.parse(args._[1]);
if (args._[2] !== '') {
let buyer = Address.parse(args._[2]);
let key = Buffer.from(args._[3], 'hex');
let signature = main.signBuy(args._[0], collection, buyer, key);
let msg = main.createItem({domain: args._[0], signature})
console.log(Base64.encode(msg.toBoc()) + ' ' + collection.toString());
} else {
let msg = main.createItem({domain: args._[0], signature: '0'})
console.log(Base64.encode(msg.toBoc()) + ' ' + collection.toString());
}
}
},
{
name: 'keygen',
command: async function keygen(args) {
let keypair = keyPairFromSeed(await getSecureRandomBytes(32));
console.log(keypair.secretKey.toString('hex'));
}
},
{
name: 'getpub', // get public key as BN from b64 secret key
options: [
{
name: 'key',
help: 'Secret key, hex-encoded'
}
],
command: function getpub(args) {
let keypair = keyPairFromSecretKey(Buffer.from(args._[0], 'base64'));
console.log(new BN(keypair.publicKey))
}
},
{
name: 'content-message',
options: [
{
name: 'domain',
help: 'domain name to set content for (test for test.example.ton)'
},
{
name: 'zone',
help: 'zone name to set content for (example.ton for test.example.ton)'
},
{
name: 'address',
help: 'address of the collection contract'
},
{
name: 'workchain',
help: '0 for mainnet, 1 for testnet'
}
],
command: function set_content(args) {
let msg = main.setContent({domain: args._[0], zone: args._[1]});
let addr = main.getItemAddr(Address.parse(args._[2]), args._[0], args._[3] === '1' ? -1 : 0);
console.log(Base64.encode(msg.toBoc()) + ' ' + addr.toString());
}
}
]
let match = subcommand(commands);
let opts = match(argv);

8
build/_build.ts

@ -19,10 +19,10 @@ async function main() {
console.log("Build script running, let's find some FunC contracts to compile..");
// if we have an explicit bin directory, use the executables there (needed for glitch.com)
if (fs.existsSync("bin")) {
process.env.PATH = path.join(__dirname, "..", "bin") + path.delimiter + process.env.PATH;
process.env.FIFTPATH = path.join(__dirname, "..", "bin", "fiftlib");
}
// if (fs.existsSync("bin")) {
// process.env.PATH = path.join(__dirname, "..", "bin") + path.delimiter + process.env.PATH;
// process.env.FIFTPATH = path.join(__dirname, "..", "bin", "fiftlib");
// }
// make sure func compiler is available
const minSupportFunc = "0.2.0";

282
build/_deploy.ts

@ -6,144 +6,160 @@
import axios from "axios";
import axiosThrottle from "axios-request-throttle";
axiosThrottle.use(axios, { requestsPerSecond: 0.5 }); // required since toncenter jsonRPC limits to 1 req/sec without API key
import dotenv from "dotenv";
dotenv.config();
import fs from "fs";
import path from "path";
import glob from "fast-glob";
import { Address, Cell, CellMessage, CommonMessageInfo, fromNano, InternalMessage, StateInit, toNano } from "ton";
import { TonClient, WalletContract, WalletV3R2Source, contractAddress, SendMode } from "ton";
import { mnemonicNew, mnemonicToWalletKey } from "ton-crypto";
import {
Address,
Cell,
CellMessage,
CommonMessageInfo,
contractAddress,
fromNano,
InternalMessage,
SendMode,
StateInit,
toNano,
WalletContract,
WalletV3R2Source
} from "ton";
import {mnemonicNew, mnemonicToWalletKey} from "ton-crypto";
import {get_tonclient} from "../contracts/utils";
axiosThrottle.use(axios, {requestsPerSecond: 0.5}); // required since toncenter jsonRPC limits to 1 req/sec without API key
dotenv.config();
async function main() {
console.log(`=================================================================`);
console.log(`Deploy script running, let's find some contracts to deploy..`);
const isTestnet = process.env.TESTNET || process.env.npm_lifecycle_event == "deploy:testnet";
// check input arguments (given through environment variables)
if (isTestnet) {
console.log(`\n* We are working with 'testnet' (https://t.me/testgiver_ton_bot will give you test TON)`);
} else {
console.log(`\n* We are working with 'mainnet'`);
}
// initialize globals
const client = new TonClient({ endpoint: `https://${isTestnet ? "testnet." : ""}toncenter.com/api/v2/jsonRPC` });
const deployerWalletType = "org.ton.wallets.v3.r2"; // also see WalletV3R2Source class used below
const newContractFunding = toNano(0.02); // this will be (almost in full) the balance of a new deployed contract and allow it to pay rent
const workchain = 0; // normally 0, only special contracts should be deployed to masterchain (-1)
// make sure we have a wallet mnemonic to deploy from (or create one if not found)
const deployConfigEnv = ".env";
let deployerMnemonic;
if (!fs.existsSync(deployConfigEnv) || !process.env.DEPLOYER_MNEMONIC) {
console.log(`\n* Config file '${deployConfigEnv}' not found, creating a new wallet for deploy..`);
deployerMnemonic = (await mnemonicNew(24)).join(" ");
const deployWalletEnvContent = `DEPLOYER_WALLET=${deployerWalletType}\nDEPLOYER_MNEMONIC="${deployerMnemonic}"\n`;
fs.writeFileSync(deployConfigEnv, deployWalletEnvContent);
console.log(` - Created new wallet in '${deployConfigEnv}' - keep this file secret!`);
} else {
console.log(`\n* Config file '${deployConfigEnv}' found and will be used for deployment!`);
deployerMnemonic = process.env.DEPLOYER_MNEMONIC;
}
// open the wallet and make sure it has enough TON
const walletKey = await mnemonicToWalletKey(deployerMnemonic.split(" "));
const walletContract = WalletContract.create(client, WalletV3R2Source.create({ publicKey: walletKey.publicKey, workchain }));
console.log(` - Wallet address used to deploy from is: ${walletContract.address.toFriendly()}`);
const walletBalance = await client.getBalance(walletContract.address);
if (walletBalance.lt(toNano(0.2))) {
console.log(` - ERROR: Wallet has less than 0.2 TON for gas (${fromNano(walletBalance)} TON), please send some TON for gas first`);
process.exit(1);
} else {
console.log(` - Wallet balance is ${fromNano(walletBalance)} TON, which will be used for gas`);
}
// go over all the contracts we have deploy scripts for
const rootContracts = glob.sync(["build/*.deploy.ts"]);
for (const rootContract of rootContracts) {
// deploy a new root contract
console.log(`\n* Found root contract '${rootContract} - let's deploy it':`);
const contractName = path.parse(path.parse(rootContract).name).name;
// prepare the init data cell
const deployInitScript = require(__dirname + "/../" + rootContract);
if (typeof deployInitScript.initData !== "function") {
console.log(` - ERROR: '${rootContract}' does not have 'initData()' function`);
process.exit(1);
}
console.log(1);
const initDataCell = deployInitScript.initData() as Cell;
console.log(2);
// prepare the init message
if (typeof deployInitScript.initMessage !== "function") {
console.log(` - ERROR: '${rootContract}' does not have 'initMessage()' function`);
process.exit(1);
}
console.log(1);
const initMessageCell = deployInitScript.initMessage() as Cell | null;
// prepare the init code cell
const hexArtifact = `build/${contractName}.compiled.json`;
if (!fs.existsSync(hexArtifact)) {
console.log(` - ERROR: '${hexArtifact}' not found, did you build?`);
process.exit(1);
}
const initCodeCell = Cell.fromBoc(JSON.parse(fs.readFileSync(hexArtifact).toString()).hex)[0];
// make sure the contract was not already deployed
const newContractAddress = contractAddress({ workchain, initialData: initDataCell, initialCode: initCodeCell });
console.log(` - Based on your init code+data, your new contract address is: ${newContractAddress.toFriendly()}`);
if (await client.isContractDeployed(newContractAddress)) {
console.log(` - Looks like the contract is already deployed in this address, skipping deployment`);
await performPostDeploymentTest(rootContract, deployInitScript, walletContract, walletKey.secretKey, newContractAddress);
continue;
console.log(`=================================================================`);
console.log(`Deploy script running, let's find some contracts to deploy..`);
const isTestnet = process.env.TESTNET || process.env.npm_lifecycle_event == "deploy:testnet";
// check input arguments (given through environment variables)
if (isTestnet) {
console.log(`\n* We are working with 'testnet' (https://t.me/testgiver_ton_bot will give you test TON)`);
} else {
console.log(`\n* We are working with 'mainnet'`);
}
// deploy by sending an internal message to the deploying wallet
console.log(` - Let's deploy the contract on-chain..`);
const seqno = await walletContract.getSeqNo();
const transfer = walletContract.createTransfer({
secretKey: walletKey.secretKey,
seqno: seqno,
sendMode: SendMode.PAY_GAS_SEPARATLY + SendMode.IGNORE_ERRORS,
order: new InternalMessage({
to: newContractAddress,
value: newContractFunding,
bounce: false,
body: new CommonMessageInfo({
stateInit: new StateInit({ data: initDataCell, code: initCodeCell }),
body: initMessageCell !== null ? new CellMessage(initMessageCell) : null,
}),
}),
});
await client.sendExternalMessage(walletContract, transfer);
console.log(` - Deploy transaction sent successfully`);
// make sure that the contract was deployed
console.log(` - Block explorer link: https://${process.env.TESTNET ? "test." : ""}tonwhales.com/explorer/address/${newContractAddress.toFriendly()}`);
console.log(` - Waiting up to 20 seconds to check if the contract was actually deployed..`);
for (let attempt = 0; attempt < 10; attempt++) {
await sleep(2000);
const seqnoAfter = await walletContract.getSeqNo();
if (seqnoAfter > seqno) break;
// initialize globals
const client = get_tonclient(isTestnet);
const deployerWalletType = "org.ton.wallets.v3.r2"; // also see WalletV3R2Source class used below
const newContractFunding = toNano(0.02); // this will be (almost in full) the balance of a new deployed contract and allow it to pay rent
const workchain = 0; // normally 0, only special contracts should be deployed to masterchain (-1)
// make sure we have a wallet mnemonic to deploy from (or create one if not found)
const deployConfigEnv = ".env";
let deployerMnemonic;
if (!fs.existsSync(deployConfigEnv) || !process.env.DEPLOYER_MNEMONIC) {
console.log(`\n* Config file '${deployConfigEnv}' not found, creating a new wallet for deploy..`);
deployerMnemonic = (await mnemonicNew(24)).join(" ");
const deployWalletEnvContent = `DEPLOYER_WALLET=${deployerWalletType}\nDEPLOYER_MNEMONIC="${deployerMnemonic}"\n`;
fs.writeFileSync(deployConfigEnv, deployWalletEnvContent);
console.log(` - Created new wallet in '${deployConfigEnv}' - keep this file secret!`);
} else {
console.log(`\n* Config file '${deployConfigEnv}' found and will be used for deployment!`);
deployerMnemonic = process.env.DEPLOYER_MNEMONIC;
}
if (await client.isContractDeployed(newContractAddress)) {
console.log(` - SUCCESS! Contract deployed successfully to address: ${newContractAddress.toFriendly()}`);
const contractBalance = await client.getBalance(newContractAddress);
console.log(` - New contract balance is now ${fromNano(contractBalance)} TON, make sure it has enough to pay rent`);
await performPostDeploymentTest(rootContract, deployInitScript, walletContract, walletKey.secretKey, newContractAddress);
// open the wallet and make sure it has enough TON
const walletKey = await mnemonicToWalletKey(deployerMnemonic.split(" "));
const walletContract = WalletContract.create(client, WalletV3R2Source.create({
publicKey: walletKey.publicKey,
workchain
}));
console.log(` - Wallet address used to deploy from is: ${walletContract.address.toFriendly()}`);
const walletBalance = await client.getBalance(walletContract.address);
if (walletBalance.lt(toNano(0.2))) {
console.log(` - ERROR: Wallet has less than 0.2 TON for gas (${fromNano(walletBalance)} TON), please send some TON for gas first`);
process.exit(1);
} else {
console.log(` - FAILURE! Contract address still looks uninitialized: ${newContractAddress.toFriendly()}`);
console.log(` - Wallet balance is ${fromNano(walletBalance)} TON, which will be used for gas`);
}
// go over all the contracts we have deploy scripts for
const rootContracts = glob.sync(["build/*.deploy.ts"]);
for (const rootContract of rootContracts) {
// deploy a new root contract
console.log(`\n* Found root contract '${rootContract} - let's deploy it':`);
const contractName = path.parse(path.parse(rootContract).name).name;
// prepare the init data cell
const deployInitScript = require(__dirname + "/../" + rootContract);
if (typeof deployInitScript.initData !== "function") {
console.log(` - ERROR: '${rootContract}' does not have 'initData()' function`);
process.exit(1);
}
console.log(1);
const initDataCell = deployInitScript.initData() as Cell;
console.log(2);
// prepare the init message
if (typeof deployInitScript.initMessage !== "function") {
console.log(` - ERROR: '${rootContract}' does not have 'initMessage()' function`);
process.exit(1);
}
console.log(1);
const initMessageCell = deployInitScript.initMessage() as Cell | null;
// prepare the init code cell
const hexArtifact = `build/${contractName}.compiled.json`;
if (!fs.existsSync(hexArtifact)) {
console.log(` - ERROR: '${hexArtifact}' not found, did you build?`);
process.exit(1);
}
const initCodeCell = Cell.fromBoc(JSON.parse(fs.readFileSync(hexArtifact).toString()).hex)[0];
// make sure the contract was not already deployed
const newContractAddress = contractAddress({workchain, initialData: initDataCell, initialCode: initCodeCell});
console.log(` - Based on your init code+data, your new contract address is: ${newContractAddress.toFriendly()}`);
if (await client.isContractDeployed(newContractAddress)) {
console.log(` - Looks like the contract is already deployed in this address, skipping deployment`);
await performPostDeploymentTest(rootContract, deployInitScript, walletContract, walletKey.secretKey, newContractAddress);
continue;
}
// deploy by sending an internal message to the deploying wallet
console.log(` - Let's deploy the contract on-chain..`);
const seqno = await walletContract.getSeqNo();
const transfer = walletContract.createTransfer({
secretKey: walletKey.secretKey,
seqno: seqno,
sendMode: SendMode.PAY_GAS_SEPARATLY + SendMode.IGNORE_ERRORS,
order: new InternalMessage({
to: newContractAddress,
value: newContractFunding,
bounce: false,
body: new CommonMessageInfo({
stateInit: new StateInit({data: initDataCell, code: initCodeCell}),
body: initMessageCell !== null ? new CellMessage(initMessageCell) : null,
}),
}),
});
await client.sendExternalMessage(walletContract, transfer);
console.log(` - Deploy transaction sent successfully`);
// make sure that the contract was deployed
console.log(` - Block explorer link: https://${process.env.TESTNET ? "test." : ""}tonwhales.com/explorer/address/${newContractAddress.toFriendly()}`);
console.log(` - Waiting up to 20 seconds to check if the contract was actually deployed..`);
for (let attempt = 0; attempt < 10; attempt++) {
await sleep(2000);
const seqnoAfter = await walletContract.getSeqNo();
if (seqnoAfter > seqno) break;
}
if (await client.isContractDeployed(newContractAddress)) {
console.log(` - SUCCESS! Contract deployed successfully to address: ${newContractAddress.toFriendly()}`);
const contractBalance = await client.getBalance(newContractAddress);
console.log(` - New contract balance is now ${fromNano(contractBalance)} TON, make sure it has enough to pay rent`);
await performPostDeploymentTest(rootContract, deployInitScript, walletContract, walletKey.secretKey, newContractAddress);
} else {
console.log(` - FAILURE! Contract address still looks uninitialized: ${newContractAddress.toFriendly()}`);
}
}
}
console.log(``);
console.log(``);
}
main();
@ -151,14 +167,14 @@ main();
// helpers
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function performPostDeploymentTest(rootContract: string, deployInitScript: any, walletContract: WalletContract, secretKey: Buffer, newContractAddress: Address) {
if (typeof deployInitScript.postDeployTest !== "function") {
console.log(` - Not running a post deployment test, '${rootContract}' does not have 'postDeployTest()' function`);
return;
}
console.log(` - Running a post deployment test:`);
await deployInitScript.postDeployTest(walletContract, secretKey, newContractAddress);
if (typeof deployInitScript.postDeployTest !== "function") {
console.log(` - Not running a post deployment test, '${rootContract}' does not have 'postDeployTest()' function`);
return;
}
console.log(` - Running a post deployment test:`);
await deployInitScript.postDeployTest(walletContract, secretKey, newContractAddress);
}

975
build/dns-auto-code.cell.fif

@ -0,0 +1,975 @@
"Asm.fif" include
"Asm.fif" include
// automatically generated from `contracts/dns-auto-code.fc` incl:`contracts/imports/stdlib.fc`
PROGRAM{
DECLPROC load_data
DECLPROC load_prices
DECLPROC store_data
DECLPROC send_message
DECLPROC send_error
DECLPROC send_ok
DECLPROC housekeeping
DECLPROC calcprice_internal
DECLPROC check_owner
DECLPROC perform_ctl_op
DECLPROC recv_internal
DECLPROC recv_external
DECLPROC dnsdictlookup
123660 DECLMETHOD dnsresolve
87450 DECLMETHOD getexpirationx
110574 DECLMETHOD getexpiration
67418 DECLMETHOD getstdperiod
109522 DECLMETHOD getppr
108994 DECLMETHOD getppc
113123 DECLMETHOD getppb
113304 DECLMETHOD calcprice
85700 DECLMETHOD calcregprice
DECLGLOBVAR query_info
load_data PROCREF:<{
//
c4 PUSH // _1
CTOS // cs
LDREF // _3 cs
LDDICT // _3 _5 cs
LDDICT // _3 _5 _7 cs
30 LDU // _3 _5 _7 _10 cs
LDGRAMS // _3 _5 _7 _10 _13 cs
LDGRAMS // _3 _5 _7 _10 _13 _15 cs
LDGRAMS // _3 _5 _7 _10 _13 _15 _17 cs
4 -ROLL // _3 _5 _7 cs _10 _13 _15 _17
4 TUPLE // _3 _5 _7 cs _9
SWAP // _3 _5 _7 _9 cs
32 LDU // _3 _5 _7 _9 _19 cs
32 LDU // _3 _5 _7 _9 _19 _42 _41
DROP // _3 _5 _7 _9 _19 _22
}>
load_prices PROCREF:<{
//
c4 PUSH // _1
CTOS // cs
LDREF // _19 _18
NIP // cs
LDDICT // _21 _20
NIP // cs
LDDICT // _23 _22
NIP // cs
30 LDU // _9 cs
LDGRAMS // _9 _12 cs
LDGRAMS // _9 _12 _14 cs
LDGRAMS // _9 _12 _14 _31 _30
DROP // _9 _12 _14 _16
}>
store_data PROC:<{
// ctl dd gc prices nhk lhk
s0 s2 XCHG // ctl dd gc lhk nhk prices
4 UNTUPLE // ctl dd gc lhk nhk sp ppr ppc ppb
s0 s8 XCHG
NEWC // ppb dd gc lhk nhk sp ppr ppc ctl _11
STREF // ppb dd gc lhk nhk sp ppr ppc _12
s1 s7 XCHG // ppb ppc gc lhk nhk sp ppr dd _12
STDICT // ppb ppc gc lhk nhk sp ppr _13
s1 s5 XCHG // ppb ppc ppr lhk nhk sp gc _13
STDICT // ppb ppc ppr lhk nhk sp _14
30 STU // ppb ppc ppr lhk nhk _16
s0 s3 XCHG2 // ppb ppc nhk lhk _16 ppr
STGRAMS // ppb ppc nhk lhk _17
s0 s3 XCHG2 // ppb lhk nhk _17 ppc
STGRAMS // ppb lhk nhk _18
s0 s3 XCHG2 // nhk lhk _18 ppb
STGRAMS // nhk lhk _19
s1 s2 XCHG // lhk nhk _19
32 STU // lhk _21
32 STU // _23
ENDC // _24
c4 POP
}>
send_message PROC:<{
// addr tag query_id body grams mode
0 PUSHINT // addr tag query_id body grams mode _7=0
24 PUSHINT // addr tag query_id body grams mode _7=0 _8=24
NEWC // addr tag query_id body grams mode _7=0 _8=24 _9
6 STU // addr tag query_id body grams mode _7=0 _11
s0 s7 XCHG2 // _7=0 tag query_id body grams mode _11 addr
STSLICER // _7=0 tag query_id body grams mode _12
ROT // _7=0 tag query_id body mode _12 grams
STGRAMS // _7=0 tag query_id body mode _13
s1 s5 XCHG // mode tag query_id body _7=0 _13
107 STU // mode tag query_id body _27
s1 s3 XCHG // mode body query_id tag _27
32 STU // mode body query_id _29
64 STU // mode body msg
OVER // mode body msg body
-1 GTINT // mode body msg _33
IF:<{ // mode body msg
32 STU // mode msg
}>ELSE<{
NIP // mode msg
}>
ENDC // mode _37
SWAP // _37 mode
SENDRAWMSG
}>
send_error PROC:<{
// error_code
query_info GETGLOB
UNTRIPLE // error_code addr query_id op
s2 s3 XCHG
0 PUSHINT
64 PUSHINT // addr error_code query_id op _5=0 _6=64
send_message CALLDICT
}>
send_ok PROC:<{
// price
4 PUSHINT // price _1=4
RAWRESERVE
query_info GETGLOB
UNTRIPLE // addr query_id op
4016791929 PUSHINT // addr query_id op _7=4016791929
-ROT
0 PUSHINT
7 PUSHPOW2 // addr _7=4016791929 query_id op _8=0 _9=128
send_message CALLDICT
}>
housekeeping PROC:<{
// ctl dd gc prices nhk lhk max_steps
NOW // ctl dd gc prices nhk lhk max_steps n
s2 PUSH // ctl dd gc prices nhk lhk max_steps n lhk
60 ADDCONST // ctl dd gc prices nhk lhk max_steps n _10
s4 s(-1) PUXC // ctl dd gc prices nhk lhk max_steps n nhk _10
MAX // ctl dd gc prices nhk lhk max_steps n _11
s1 s(-1) PUXC // ctl dd gc prices nhk lhk max_steps n n _11
LESS // ctl dd gc prices nhk lhk max_steps n _12
IFJMP:<{ // ctl dd gc prices nhk lhk max_steps n
2DROP // ctl dd gc prices nhk lhk
store_data CALLDICT
}> // ctl dd gc prices nhk lhk max_steps n
s2 POP // ctl dd gc prices nhk n max_steps
s4 PUSH
8 PUSHPOW2 // ctl dd gc prices nhk n max_steps gc _17=256
DICTUMIN
NULLSWAPIFNOT2 // ctl dd gc prices nhk n max_steps _63 _62 _64
s2 POP // ctl dd gc prices nhk n max_steps found? mkey
WHILE:<{
s1 s2 XCPU // ctl dd gc prices nhk n max_steps mkey found? max_steps
AND // ctl dd gc prices nhk n max_steps mkey _19
}>DO<{ // ctl dd gc prices nhk n max_steps mkey
s3 POP // ctl dd gc prices mkey n max_steps
s2 PUSH // ctl dd gc prices mkey n max_steps mkey
224 RSHIFT# // ctl dd gc prices mkey n max_steps nhk
s0 s2 PUSH2 // ctl dd gc prices mkey n max_steps nhk nhk n
LESS // ctl dd gc prices mkey n max_steps nhk _24
IF:<{ // ctl dd gc prices mkey n max_steps nhk
DROP // ctl dd gc prices mkey n max_steps
s2 PUSH // ctl dd gc prices mkey n max_steps mkey
224 MODPOW2# // ctl dd gc prices mkey n max_steps key
s0 s6 PUSH2
224 PUSHINT // ctl dd gc prices mkey n max_steps key key dd _35
DICTUGET
NULLSWAPIFNOT // ctl dd gc prices mkey n max_steps key val found?
IF:<{ // ctl dd gc prices mkey n max_steps key val
32 PLDU // ctl dd gc prices mkey n max_steps key exp
s3 PUSH // ctl dd gc prices mkey n max_steps key exp n
LEQ // ctl dd gc prices mkey n max_steps key _40
IF:<{ // ctl dd gc prices mkey n max_steps key
s0 s6 XCHG2
224 PUSHINT // ctl max_steps gc prices mkey n key dd _44
DICTUDEL // ctl max_steps gc prices mkey n _67 _68
DROP // ctl max_steps gc prices mkey n dd
s0 s5 XCHG // ctl dd gc prices mkey n max_steps
}>ELSE<{
DROP // ctl dd gc prices mkey n max_steps
}>
}>ELSE<{
2DROP // ctl dd gc prices mkey n max_steps
}>
s2 s4 XCHG2
8 PUSHPOW2 // ctl dd max_steps prices n mkey gc _47=256
DICTUDEL // ctl dd max_steps prices n _69 _70
DROP // ctl dd max_steps prices n gc
DUP
8 PUSHPOW2 // ctl dd max_steps prices n gc gc _50=256
DICTUMIN
NULLSWAPIFNOT2 // ctl dd max_steps prices n gc _72 _71 _73
s2 POP // ctl dd max_steps prices n gc found? mkey
OVER // ctl dd max_steps prices n gc found? mkey found?
IF:<{ // ctl dd max_steps prices n gc found? mkey
DUP // ctl dd max_steps prices n gc found? mkey mkey
224 RSHIFT# // ctl dd max_steps prices n gc found? mkey _52
}>ELSE<{ // ctl dd max_steps prices n gc found? mkey
32 PUSHPOW2DEC // ctl dd max_steps prices n gc found? mkey _52=4294967295
}> // ctl dd max_steps prices n gc found? mkey nhk
s0 s6 XCHG // ctl dd nhk prices n gc found? mkey max_steps
DEC // ctl dd nhk prices n gc found? mkey max_steps
}>ELSE<{ // ctl dd gc prices mkey n max_steps nhk
s5 s1 s5 XCHG3
s0 s3 XCHG
FALSE
s0 s2 XCHG // ctl dd nhk prices n gc found? mkey max_steps
}>
s3 s6 XCHG
s3 s4 XCHG
-ROT // ctl dd gc prices nhk n max_steps found? mkey
}> // ctl dd gc prices nhk n max_steps mkey
2DROP // ctl dd gc prices nhk n
store_data CALLDICT
}>
calcprice_internal PROCREF:<{
// domain data ppc ppb
s0 s2 XCHG
100 PUSHINT // domain ppb ppc data _7=100
CDATASIZE // domain ppb ppc _24 _25 _26
s2 POP // domain ppb ppc refs bits
s0 s4 XCHG // bits ppb ppc refs domain
SBITS // bits ppb ppc refs _9
1 LSHIFT# // bits ppb ppc refs _11
192 PUSHINT // bits ppb ppc refs _11 _16
ADD // bits ppb ppc refs _17
s1 s4 XCHG // refs ppb ppc bits _17
ADD // refs ppb ppc bits
s0 s3 XCHG // bits ppb ppc refs
2 ADDCONST // bits ppb ppc _20
MUL // bits ppb _21
s0 s2 XCHG // _21 ppb bits
MUL // _21 _22
ADD // _23
}>
check_owner PROCREF:<{
// cat_table owner_info src_wc src_addr strict
s0 s4 XCHG // strict owner_info src_wc src_addr cat_table
ISNULL // strict owner_info src_wc src_addr _5
s4 s(-1) PUXC // strict owner_info src_wc src_addr strict _5
AND // strict owner_info src_wc src_addr _6
IFJMP:<{ // strict owner_info src_wc src_addr
4 BLKDROP //
4000281702 PUSHINT // _7=4000281702
}> // strict owner_info src_wc src_addr
s2 PUSH // strict owner_info src_wc src_addr owner_info
ISNULL // strict owner_info src_wc src_addr _8
IFJMP:<{ // strict owner_info src_wc src_addr
3 BLKDROP // strict
4000263474 PUSHINT // strict _9=4000263474
AND // _10
}> // strict owner_info src_wc src_addr
s3 POP // src_addr owner_info src_wc
3798033458 PUSHINT // src_addr owner_info src_wc ERR_BAD2=3798033458
s0 s2 XCHG // src_addr ERR_BAD2=3798033458 src_wc owner_info
CTOS // src_addr ERR_BAD2=3798033458 src_wc sown
DUP // src_addr ERR_BAD2=3798033458 src_wc sown sown
SBITS // src_addr ERR_BAD2=3798033458 src_wc sown _15
283 PUSHINT // src_addr ERR_BAD2=3798033458 src_wc sown _15 _22
LESS // src_addr ERR_BAD2=3798033458 src_wc sown _23
IFJMP:<{ // src_addr ERR_BAD2=3798033458 src_wc sown
s2 s3 XCHG
3 BLKDROP // ERR_BAD2=3798033458
}> // src_addr ERR_BAD2=3798033458 src_wc sown
19 LDU // src_addr ERR_BAD2=3798033458 src_wc _24 sown
SWAP
327324 PUSHINT // src_addr ERR_BAD2=3798033458 src_wc sown _24 _33
NEQ // src_addr ERR_BAD2=3798033458 src_wc sown _34
IFJMP:<{ // src_addr ERR_BAD2=3798033458 src_wc sown
s2 s3 XCHG
3 BLKDROP // ERR_BAD2=3798033458
}> // src_addr ERR_BAD2=3798033458 src_wc sown
1 2 BLKDROP2 // src_addr src_wc sown
8 LDI // src_addr src_wc _37 sown
256 PLDU // src_addr src_wc owner_wc owner_addr
s0 s2 XCHG // src_addr owner_addr owner_wc src_wc
NEQ // src_addr owner_addr _42
s0 s2 XCHG // _42 owner_addr src_addr
NEQ // _42 _43
OR // _44
IFJMP:<{ //
4000282478 PUSHINT // _45=4000282478
}> //
0 PUSHINT // _46=0
}>
perform_ctl_op PROCREF:<{
// op src_wc src_addr in_msg
load_data INLINECALLDICT // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk
s5 PUSH // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk ctl
CTOS // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk cs
8 LDI // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk _13 cs
s0 s10 XCHG // op cs src_addr in_msg ctl domdata gc prices nhk lhk _13 src_wc
NEQ // op cs src_addr in_msg ctl domdata gc prices nhk lhk _16
s0 s9 XCHG // op _16 src_addr in_msg ctl domdata gc prices nhk lhk cs
256 LDU // op _16 src_addr in_msg ctl domdata gc prices nhk lhk _83 _82
DROP // op _16 src_addr in_msg ctl domdata gc prices nhk lhk _17
s0 s8 XCHG2 // op _16 lhk in_msg ctl domdata gc prices nhk _17 src_addr
NEQ // op _16 lhk in_msg ctl domdata gc prices nhk _20
s1 s8 XCHG // op nhk lhk in_msg ctl domdata gc prices _16 _20
OR // op nhk lhk in_msg ctl domdata gc prices _21
IFJMP:<{ // op nhk lhk in_msg ctl domdata gc prices
8 BLKDROP //
4000282478 PUSHINT // _22=4000282478
send_error CALLDICT
}> // op nhk lhk in_msg ctl domdata gc prices
s0 s7 XCHG
1130909810 PUSHINT // prices nhk lhk in_msg ctl domdata gc op _24=1130909810
EQUAL // prices nhk lhk in_msg ctl domdata gc _25
IFJMP:<{ // prices nhk lhk in_msg ctl domdata gc
s6 POP // gc nhk lhk in_msg ctl domdata
s0 s2 XCHG // gc nhk lhk domdata ctl in_msg
32 LDU // gc nhk lhk domdata ctl _30 in_msg
LDGRAMS // gc nhk lhk domdata ctl _30 _33 in_msg
LDGRAMS // gc nhk lhk domdata ctl _30 _33 _35 in_msg
LDGRAMS // gc nhk lhk domdata ctl stdper ppr ppc ppb in_msg
ENDS
4 TUPLE // gc nhk lhk domdata ctl _40
s0 s4 s4 XCHG3
s0 s5 XCHG
s0 s3 XCHG // ctl domdata gc _40 nhk lhk
store_data CALLDICT
0 PUSHINT // _42=0
send_ok CALLDICT
}> // prices nhk lhk in_msg ctl domdata gc
s4 POP // prices nhk gc in_msg ctl domdata
query_info GETGLOB
UNTRIPLE // prices nhk gc in_msg ctl domdata addr query_id op
DUP
1128555884 PUSHINT // prices nhk gc in_msg ctl domdata addr query_id op op _48=1128555884
EQUAL // prices nhk gc in_msg ctl domdata addr query_id op _49
IFJMP:<{ // prices nhk gc in_msg ctl domdata addr query_id op
s5 POP // prices nhk gc op ctl domdata addr query_id
s2 PUSH // prices nhk gc op ctl domdata addr query_id domdata
ISNULL // prices nhk gc op ctl domdata addr query_id _50
IFNOT:<{ // prices nhk gc op ctl domdata addr query_id
s3 s4 XCHG
s2 s3 XCHG
s5 s7 s6 XCHG3
1 PUSHINT
-1 PUSHINT // addr query_id op ctl domdata gc prices nhk _51=1 _52=-1
housekeeping CALLDICT
-ROT // op addr query_id
}>ELSE<{
s4 s7 XCHG
5 2 BLKDROP2 // op addr query_id
}>
load_data INLINECALLDICT // op addr query_id _95 _96 _97 _98 _99 _100
s4 s5 XCHG
5 BLKDROP // op addr query_id domdata
ISNULL // op addr query_id _55
IFNOTJMP:<{ // op addr query_id
3 BLKDROP //
4000605549 PUSHINT // _56=4000605549
send_error CALLDICT
}> // op addr query_id
4016791929 PUSHINT // op addr query_id _58=4016791929
s0 s1 s3 XCHG3
0 PUSHINT
160 PUSHINT // addr _58=4016791929 query_id op _59=0 _62
send_message CALLDICT
}> // prices nhk gc in_msg ctl domdata addr query_id op
s3 POP
s3 POP
s4 POP
s4 POP
s4 POP // query_id op addr in_msg
s2 PUSH
1415670629 PUSHINT // query_id op addr in_msg op _64=1415670629
EQUAL // query_id op addr in_msg _65
IFJMP:<{ // query_id op addr in_msg
LDGRAMS // query_id op addr _102 _101
DROP // query_id op addr amount
s1 s3 XCHG
4016791929 PUSHINT
s3 s3 XCHG2
64 PUSHINT // addr _69=4016791929 query_id op amount _70=64
send_message CALLDICT
}> // query_id op addr in_msg
4 BLKDROP //
32 PUSHPOW2DEC // _72=4294967295
send_error CALLDICT
}>
recv_internal PROC:<{
// msg_value in_msg_cell in_msg
DUP // msg_value in_msg_cell in_msg in_msg
SBITS // msg_value in_msg_cell in_msg _3
32 LESSINT // msg_value in_msg_cell in_msg _5
IFJMP:<{ // msg_value in_msg_cell in_msg
3 BLKDROP //
}> // msg_value in_msg_cell in_msg
SWAP // msg_value in_msg in_msg_cell
CTOS // msg_value in_msg cs
4 LDU // msg_value in_msg flags cs
SWAP
1 PUSHINT // msg_value in_msg cs flags _12=1
AND // msg_value in_msg cs _13
IFJMP:<{ // msg_value in_msg cs
3 BLKDROP //
}> // msg_value in_msg cs
LDMSGADDR // msg_value in_msg _327 _326
DROP // msg_value in_msg s_addr
DUP // msg_value in_msg s_addr s_addr
REWRITESTDADDR // msg_value in_msg s_addr src_wc src_addr
s0 s3 XCHG // msg_value src_addr s_addr src_wc in_msg
32 LDU // msg_value src_addr s_addr src_wc op in_msg
OVER // msg_value src_addr s_addr src_wc op in_msg op
IFNOTJMP:<{ // msg_value src_addr s_addr src_wc op in_msg
6 BLKDROP //
}> // msg_value src_addr s_addr src_wc op in_msg
0 PUSHINT // msg_value src_addr s_addr src_wc op in_msg query_id=0
OVER // msg_value src_addr s_addr src_wc op in_msg query_id=0 in_msg
SBITS // msg_value src_addr s_addr src_wc op in_msg query_id=0 _26
63 GTINT // msg_value src_addr s_addr src_wc op in_msg query_id=0 _28
IF:<{ // msg_value src_addr s_addr src_wc op in_msg query_id=0
DROP // msg_value src_addr s_addr src_wc op in_msg
64 LDU // msg_value src_addr s_addr src_wc op query_id in_msg
SWAP // msg_value src_addr s_addr src_wc op in_msg query_id
}> // msg_value src_addr s_addr src_wc op in_msg query_id
s4 s0 s2 XC2PU // msg_value src_addr in_msg src_wc op s_addr query_id op
TRIPLE
query_info SETGLOB
DUP
31 PUSHPOW2 // msg_value src_addr in_msg src_wc op op _34
AND // msg_value src_addr in_msg src_wc op _35
IFJMP:<{ // msg_value src_addr in_msg src_wc op
5 BLKDROP //
}> // msg_value src_addr in_msg src_wc op
DUP // msg_value src_addr in_msg src_wc op op
24 RSHIFT# // msg_value src_addr in_msg src_wc op _37
67 EQINT // msg_value src_addr in_msg src_wc op _39
IFJMP:<{ // msg_value src_addr in_msg src_wc op
s4 POP // op src_addr in_msg src_wc
-ROT // op src_wc src_addr in_msg
perform_ctl_op INLINECALLDICT
}> // msg_value src_addr in_msg src_wc op
DUP
1919248228 PUSHINT // msg_value src_addr in_msg src_wc op op _42=1919248228
EQUAL // msg_value src_addr in_msg src_wc op _45
OVER
1886547820 PUSHINT // msg_value src_addr in_msg src_wc op _45 op _46=1886547820
EQUAL // msg_value src_addr in_msg src_wc op _45 _47
1 LSHIFT# // msg_value src_addr in_msg src_wc op _45 _49
ADD // msg_value src_addr in_msg src_wc op _50
OVER
1970300004 PUSHINT // msg_value src_addr in_msg src_wc op _50 op _51=1970300004
EQUAL // msg_value src_addr in_msg src_wc op _50 _52
2 LSHIFT# // msg_value src_addr in_msg src_wc op _50 _54
ADD // msg_value src_addr in_msg src_wc op _55
SWAP
1735354211 PUSHINT // msg_value src_addr in_msg src_wc _55 op _56=1735354211
EQUAL // msg_value src_addr in_msg src_wc _55 _57
3 LSHIFT# // msg_value src_addr in_msg src_wc _55 _59
ADD // msg_value src_addr in_msg src_wc qt
DUP // msg_value src_addr in_msg src_wc qt qt
IFNOTJMP:<{ // msg_value src_addr in_msg src_wc qt
5 BLKDROP //
32 PUSHPOW2DEC // _61=4294967295
send_error CALLDICT
}> // msg_value src_addr in_msg src_wc qt
NEGATE // msg_value src_addr in_msg src_wc qt
load_data INLINECALLDICT // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk
s6 PUSH // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk qt
8 EQINT // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk _72
IFJMP:<{ // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk
DROP
s5 POP
s5 POP
s6 POP
s6 POP // domdata gc in_msg prices nhk ctl
s0 s3 XCHG // domdata gc ctl prices nhk in_msg
32 LDI // domdata gc ctl prices nhk _341 _340
DROP // domdata gc ctl prices nhk max_steps
s3 s5 XCHG
s3 s4 XCHG
1 PUSHINT
SWAP // ctl domdata gc prices nhk _77=1 max_steps
housekeeping CALLDICT
4016791929 PUSHINT // _79=4016791929
send_error CALLDICT
}> // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk
s0 s8 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg
LDOPTREF // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg
OVER // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg domain_cell
ISNULL // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg _88
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg
NIP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg
6 LDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk bytes in_msg
OVER // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk bytes in_msg bytes
0 EQINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk bytes in_msg fail
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail in_msg bytes
3 LSHIFT# // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail in_msg _97
LDSLICEX // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
}>ELSE<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain_cell
CTOS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
DUP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain domain
SBITREFS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain bits refs
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs bits
-8 ADDCONST // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs _104
-121 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs _104 _107
AND // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs _108
OR // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain fail
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
}>
s2 PUSH // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg fail
IFNOT:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
s2 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
DUP
8 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain domain _110=8
SDCUTLAST // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain _111
8 PLDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain fail
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain fail
IFJMP:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
12 BLKDROP //
4000275504 PUSHINT // _114=4000275504
send_error CALLDICT
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
NOW // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n
PUSHNULL // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n _120
DUP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info
0 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info _124=0
s0 s0 s4 PUSH3 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail
DUP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail tail
SBITS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail _126
3 RSHIFTC# // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail _128
REPEAT:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
PUSHNULL
s6 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
8 LDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp _131 tail
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail _131
0 EQINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail z
s3 s3 XCPU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key z exp tail zeros z
SUB // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key z exp tail zeros
s0 s3 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail z
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
s3 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp
s2 PUSH // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp tail
SBITS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp _137
s7 s(-1) PUXC // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp domain _137
SDSKIPLAST // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp _138
SHA256U // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp _139
32 RSHIFT# // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key
s0 s12 PUSH2
224 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key key domdata _146
DICTUGET
NULLSWAPIFNOT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key val found?
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key val
1 2 BLKDROP2 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key val
32 LDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val
s1 s7 PUSH2 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val exp n
GEQ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val _151
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val
LDREF // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cat_table val
ENDS
0 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cat_table _158=0
SWAP
8 PUSHPOW2 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp _158=0 cat_table _159=256
DICTUGETREF // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cown ok
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cown
s5 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp
}>ELSE<{
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp
}>
}>ELSE<{
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp
}>
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key
}>ELSE<{
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key
}>
s0 s3 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
}>
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp zeros
4 GTINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp _162
IFJMP:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp
15 BLKDROP
2DROP //
4017511472 PUSHINT // _163=4017511472
send_error CALLDICT
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp
s12 PUSH // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp qt
1 NEQINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp _167
s4 PUSH
s0 s4 XCHG
s15 s1 s3 XCHG3
s0 17 s() XCHG
SWAP // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table cat_table owner_info src_wc src_addr _167
check_owner INLINECALLDICT // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err
DUP // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err err
IFJMP:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err
14 1 BLKDROP2 // err
send_error CALLDICT
}> // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err
DROP // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table
s9 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table qt
2 NEQINT // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table _173
IF:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table
s0 s3 XCHG // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n in_msg
LDREF // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n _361 _360
DROP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
DUP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data data
DICTEMPTY // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _176
IFNOT:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
0 PUSHINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _179=0
OVER
8 PUSHPOW2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _179=0 data _180=256
DICTUGETREF // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data oinfo ok
IF:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data oinfo
CTOS // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs
DUP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs cs
SBITS // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs _185
283 PUSHINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs _185 _192
GEQ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs _193
31 THROWIFNOT
19 PLDU // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _197
327324 PUSHINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _197 _202
EQUAL // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _203
31 THROWIFNOT
}>ELSE<{
DROP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
}>
DUP
8 PUSHPOW2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data data _208=256
DICTUMIN
NULLSWAPIFNOT2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _365 _364 _366
2 1 BLKDROP2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok
OVER
8 PUSHPOW2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok data _213=256
DICTUMAX
NULLSWAPIFNOT2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok _368 _367 _369
2 1 BLKDROP2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok maxok
AND // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _216
31 THROWIFNOT
}> // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
}>ELSE<{ // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table
s3 POP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n
s2 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
}>
s5 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data prices
4 UNTUPLE // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb
s3 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb stdper
IFNOTJMP:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb
15 BLKDROP
3 BLKDROP //
3545187910 PUSHINT // _223=3545187910
send_error CALLDICT
}> // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb
s4 PUSH
s3 s7 XCHG
-ROT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper domain data ppc ppb
calcprice_internal INLINECALLDICT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper _226
s11 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper _226 qt
4 NEQINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper _226 _228
s1 s5 XCHG // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table _226 n data stdper ppr _228
AND // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table _226 n data stdper _229
s1 s4 XCHG // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _226 _229
ADD // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data price
s0 s14 XCHG
30 PUSHPOW2 // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data msg_value _233
SUB // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _234
s14 PUSH // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _234 price
LESS // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _235
IFJMP:<{ // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
14 BLKDROP //
3883023472 PUSHINT // _236=3883023472
send_error CALLDICT
}> // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s9 PUSH // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data qt
2 EQINT // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _243
IFJMP:<{ // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s3 POP
s8 POP // price key lhk exp n ctl domdata gc prices nhk data stdper
s7 s7 XCPU // price key lhk exp stdper ctl domdata gc prices nhk data n stdper
ADD // price key lhk exp stdper ctl domdata gc prices nhk data _244
s8 s(-1) PUXC // price key lhk exp stdper ctl domdata gc prices nhk data exp _244
GREATER // price key lhk exp stdper ctl domdata gc prices nhk data _245
IFJMP:<{ // price key lhk exp stdper ctl domdata gc prices nhk data
11 BLKDROP //
4083511919 PUSHINT // _246=4083511919
send_error CALLDICT
}> // price key lhk exp stdper ctl domdata gc prices nhk data
s7 s6 PUSH2 // price key lhk exp stdper ctl domdata gc prices nhk data exp stdper
ADD // price key lhk exp stdper ctl domdata gc prices nhk data _249
NEWC // price key lhk exp stdper ctl domdata gc prices nhk data _249 _250
32 STU // price key lhk exp stdper ctl domdata gc prices nhk data _252
STREF // price key lhk exp stdper ctl domdata gc prices nhk _253
s0 s9 s4 XCPUXC
224 PUSHINT // price key lhk exp stdper ctl nhk gc prices _253 key domdata _256
DICTUSETB // price key lhk exp stdper ctl nhk gc prices domdata
s0 s6 XCHG // price key lhk domdata stdper ctl nhk gc prices exp
224 LSHIFT# // price key lhk domdata stdper ctl nhk gc prices _262
s0 s8 XCHG2 // price prices lhk domdata stdper ctl nhk gc _262 key
ADD // price prices lhk domdata stdper ctl nhk gc gckeyO
s0 s4 XCHG // price prices lhk domdata gckeyO ctl nhk gc stdper
224 LSHIFT# // price prices lhk domdata gckeyO ctl nhk gc _268
s4 s(-1) PUXC // price prices lhk domdata gckeyO ctl nhk gc gckeyO _268
ADD // price prices lhk domdata gckeyO ctl nhk gc gckeyN
s4 s4 XCHG2
8 PUSHPOW2 // price prices lhk domdata gckeyN ctl nhk gckeyO gc _271=256
DICTUDEL // price prices lhk domdata gckeyN ctl nhk _376 _377
DROP // price prices lhk domdata gckeyN ctl nhk gc
NEWC // price prices lhk domdata gckeyN ctl nhk gc _274
s0 s4 s4 XCHG3
8 PUSHPOW2 // price prices lhk domdata nhk ctl _274 gckeyN gc _275=256
DICTUSETB // price prices lhk domdata nhk ctl gc
s0 s3 XCHG
s5 s5 s4 XCHG3
1 PUSHINT // price ctl domdata gc prices nhk lhk _277=1
housekeeping CALLDICT
send_ok CALLDICT
}> // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s9 PUSH // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data qt
1 EQINT // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _281
IFJMP:<{ // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s9 POP
s9 POP // price key lhk n data ctl domdata gc prices nhk cat_table stdper
SWAP // price key lhk n data ctl domdata gc prices nhk stdper cat_table
ISNULL // price key lhk n data ctl domdata gc prices nhk stdper _282
IFNOTJMP:<{ // price key lhk n data ctl domdata gc prices nhk stdper
11 BLKDROP //
3781980773 PUSHINT // _283=3781980773
send_error CALLDICT
}> // price key lhk n data ctl domdata gc prices nhk stdper
s1 s7 XCHG // price key lhk nhk data ctl domdata gc prices n stdper
ADD // price key lhk nhk data ctl domdata gc prices expires_at
DUP
NEWC // price key lhk nhk data ctl domdata gc prices expires_at expires_at _288
32 STU // price key lhk nhk data ctl domdata gc prices expires_at _290
s1 s6 XCHG // price key lhk nhk expires_at ctl domdata gc prices data _290
STREF // price key lhk nhk expires_at ctl domdata gc prices _291
s0 s8 s3 XCPUXC
224 PUSHINT // price key lhk nhk expires_at ctl prices gc _291 key domdata _294
DICTUSETB // price key lhk nhk expires_at ctl prices gc domdata
s4 PUSH // price key lhk nhk expires_at ctl prices gc domdata expires_at
224 LSHIFT# // price key lhk nhk expires_at ctl prices gc domdata _300
s0 s8 XCHG2 // price domdata lhk nhk expires_at ctl prices gc _300 key
OR // price domdata lhk nhk expires_at ctl prices gc gckey
NEWC // price domdata lhk nhk expires_at ctl prices gc gckey _303
s0 s2 XCHG
8 PUSHPOW2 // price domdata lhk nhk expires_at ctl prices _303 gckey gc _304=256
DICTUSETB // price domdata lhk nhk expires_at ctl prices gc
s4 s3 XCHG2 // price domdata lhk prices gc ctl nhk expires_at
MIN // price domdata lhk prices gc ctl _306
s1 s5 XCHG
s3 s0 s4 XCHG3
1 PUSHINT // price ctl domdata gc prices _306 lhk _307=1
housekeeping CALLDICT
send_ok CALLDICT
}> // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
3 1 BLKDROP2 // price key lhk exp qt ctl domdata gc prices nhk data
s0 s6 XCHG // price key lhk exp data ctl domdata gc prices nhk qt
4 EQINT // price key lhk exp data ctl domdata gc prices nhk _311
IFJMP:<{ // price key lhk exp data ctl domdata gc prices nhk
s0 s6 XCHG
NEWC // price key lhk nhk data ctl domdata gc prices exp _313
32 STU // price key lhk nhk data ctl domdata gc prices _315
s1 s5 XCHG // price key lhk nhk prices ctl domdata gc data _315
STREF // price key lhk nhk prices ctl domdata gc _316
s7 s2 XCHG2
224 PUSHINT // price gc lhk nhk prices ctl _316 key domdata _319
DICTUSETB // price gc lhk nhk prices ctl domdata
s5 s4 XCHG2
s1 s3 XCHG
1 PUSHINT // price ctl domdata gc prices nhk lhk _321=1
housekeeping CALLDICT
send_ok CALLDICT
}> // price key lhk exp data ctl domdata gc prices nhk
10 BLKDROP //
}>
recv_external PROC:<{
// in_msg
DROP //
load_data INLINECALLDICT // _12 _13 _14 _15 _16 _17
NIP // ctl dd gc prices lhk
IFNOTJMP:<{ // ctl dd gc prices
ACCEPT
32 PUSHPOW2DEC // ctl dd gc prices _9=4294967295
NOW // ctl dd gc prices _9=4294967295 _10
store_data CALLDICT
}> // ctl dd gc prices
4 BLKDROP //
}>
dnsdictlookup PROCREF:<{
// domain nowtime
OVER // domain nowtime domain
SBITREFS // domain nowtime bits refs
OVER
7 PUSHINT // domain nowtime bits refs bits _6=7
AND // domain nowtime bits refs _7
OR // domain nowtime bits _8
30 THROWIF
DUP // domain nowtime bits bits
IFNOT:<{ // domain nowtime bits
30 THROW
}> // domain nowtime bits
s2 PUSH
8 PUSHINT // domain nowtime bits domain _13=8
SDCUTLAST // domain nowtime bits _14
8 PLDU // domain nowtime bits domain_last_byte
IF:<{ // domain nowtime bits
0 PUSHINT // domain nowtime bits _17=0
NEWC // domain nowtime bits _17=0 _18
s0 s4 XCHG2 // _17=0 nowtime bits _18 domain
STSLICER // _17=0 nowtime bits _19
s1 s3 XCHG // bits nowtime _17=0 _19
8 STU // bits nowtime _21
ENDC // bits nowtime _22
CTOS // bits nowtime domain
s0 s2 XCHG // domain nowtime bits
8 ADDCONST // domain nowtime bits
}> // domain nowtime bits
DUP // domain nowtime bits bits
8 EQINT // domain nowtime bits _27
IFJMP:<{ // domain nowtime bits
3 BLKDROP //
0 PUSHINT // _28=0
PUSHNULL // _28=0 _29
8 PUSHINT // _28=0 _29 _30=8
PUSHNULL // _28=0 _29 _30=8 _31
}> // domain nowtime bits
s2 PUSH // domain nowtime bits domain
8 PLDU // domain nowtime bits domain_first_byte
0 EQINT // domain nowtime bits _36
IF:<{ // domain nowtime bits
s0 s2 XCHG // bits nowtime domain
8 LDU // bits nowtime _95 _94
NIP // bits nowtime domain
s0 s2 XCHG // domain nowtime bits
-8 ADDCONST // domain nowtime bits
}> // domain nowtime bits
c4 PUSH // domain nowtime bits _43
CTOS // domain nowtime bits ds
LDREF // domain nowtime bits _97 _96
NIP // domain nowtime bits ds
LDDICT // domain nowtime bits _99 _98
DROP // domain nowtime bits root
PUSHNULL // domain nowtime bits root val
-1 PUSHINT // domain nowtime bits root val tail_bits=-1
s5 PUSH // domain nowtime bits root val tail_bits=-1 tail
s0 s4 XCHG // domain nowtime tail root val tail_bits=-1 bits
3 RSHIFT# // domain nowtime tail root val tail_bits=-1 _57
REPEAT:<{ // domain nowtime tail root val tail_bits
s0 s3 XCHG // domain nowtime tail_bits root val tail
8 LDU // domain nowtime tail_bits root val _58 tail
SWAP // domain nowtime tail_bits root val tail _58
0 EQINT // domain nowtime tail_bits root val tail _62
IF:<{ // domain nowtime tail_bits root val tail
DUP // domain nowtime tail_bits root val tail tail
SBITS // domain nowtime tail_bits root val tail _64
s6 s(-1) PUXC // domain nowtime tail_bits root val tail domain _64
SDSKIPLAST // domain nowtime tail_bits root val tail _65
SHA256U // domain nowtime tail_bits root val tail _66
32 RSHIFT# // domain nowtime tail_bits root val tail key
s3 PUSH
224 PUSHINT // domain nowtime tail_bits root val tail key root _73
DICTUGET
NULLSWAPIFNOT // domain nowtime tail_bits root val tail v found?
IF:<{ // domain nowtime tail_bits root val tail v
DUP // domain nowtime tail_bits root val tail v v
32 PLDU // domain nowtime tail_bits root val tail v _76
s6 PUSH // domain nowtime tail_bits root val tail v _76 nowtime
GEQ // domain nowtime tail_bits root val tail v _77
IF:<{ // domain nowtime tail_bits root val tail v
s2 POP
s3 POP // domain nowtime tail root val
s2 PUSH // domain nowtime tail root val tail
SBITS // domain nowtime tail root val tail_bits
s0 s3 XCHG // domain nowtime tail_bits root val tail
}>ELSE<{
DROP // domain nowtime tail_bits root val tail
}>
}>ELSE<{
DROP // domain nowtime tail_bits root val tail
}>
}> // domain nowtime tail_bits root val tail
s0 s3 XCHG // domain nowtime tail root val tail_bits
}>
2 2 BLKDROP2
s2 POP // domain tail_bits val
DUP // domain tail_bits val val
ISNULL // domain tail_bits val _79
IFJMP:<{ // domain tail_bits val
3 BLKDROP //
0 PUSHINT // _80=0
PUSHNULL // _80=0 _81
OVER // _80=0 _81 _82=0
PUSHNULL // _80=0 _81 _82=0 _83
}> // domain tail_bits val
32 LDU // domain tail_bits _84 val
LDREF // domain tail_bits _84 _107 _106
DROP // domain tail_bits _84 _87
s2 PUSH // domain tail_bits _84 _87 tail_bits
0 EQINT // domain tail_bits _84 _87 _90
s4 s3 XCHG2 // _87 _90 _84 domain tail_bits
SDSKIPLAST // _87 _90 _84 _91
s3 s3 s0 XCHG3 // _84 _87 _90 _91
}>
dnsresolve PROC:<{
// domain category
SWAP
NOW // category domain _6
dnsdictlookup INLINECALLDICT // category exp cat_table exact? pfx
s0 s3 XCHG // category pfx cat_table exact? exp
IFNOTJMP:<{ // category pfx cat_table exact?
3 1 BLKDROP2 // exact?
PUSHNULL // exact? _8
}> // category pfx cat_table exact?
IFNOT:<{ // category pfx cat_table
11732114750494247458678882651681748623800183221773167493832867265755123357695 PUSHINT
s3 POP // category=11732114750494247458678882651681748623800183221773167493832867265755123357695 pfx cat_table
}> // category pfx cat_table
SWAP // category cat_table pfx
SBITS // category cat_table pfx_bits
s2 PUSH // category cat_table pfx_bits category
IFJMP:<{ // category cat_table pfx_bits
-ROT
8 PUSHPOW2 // pfx_bits category cat_table _13=256
DICTUGETOPTREF // pfx_bits cat_found
}> // category cat_table pfx_bits
s2 POP // pfx_bits cat_table
}>
getexpirationx PROCINLINE:<{
// domain nowtime
dnsdictlookup INLINECALLDICT // _7 _8 _9 _10
3 BLKDROP // exp
}>
getexpiration PROC:<{
// domain
NOW // domain _1
getexpirationx INLINECALLDICT // _2
}>
getstdperiod PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
3 BLKDROP // stdper
}>
getppr PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
s2 s3 XCHG
3 BLKDROP // ppr
}>
getppc PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
s1 s3 XCHG
3 BLKDROP // ppc
}>
getppb PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
3 1 BLKDROP2 // ppb
}>
calcprice PROC:<{
// domain val
load_prices INLINECALLDICT // domain val _8 _9 _10 _11
2 2 BLKDROP2 // domain val ppc ppb
calcprice_internal INLINECALLDICT // _7
}>
calcregprice PROC:<{
// domain val
load_prices INLINECALLDICT // domain val _9 _10 _11 _12
s3 POP // domain val ppb ppr ppc
s3 s4 XCHG
s4 s0 s4 XCHG3 // ppr domain val ppc ppb
calcprice_internal INLINECALLDICT // ppr _7
ADD // _8
}>
}END>c
boc>B "build/dns-auto-code.cell" B>file

972
build/dns-auto-code.fif

@ -0,0 +1,972 @@
"Asm.fif" include
// automatically generated from `contracts/dns-auto-code.fc` incl:`contracts/imports/stdlib.fc`
PROGRAM{
DECLPROC load_data
DECLPROC load_prices
DECLPROC store_data
DECLPROC send_message
DECLPROC send_error
DECLPROC send_ok
DECLPROC housekeeping
DECLPROC calcprice_internal
DECLPROC check_owner
DECLPROC perform_ctl_op
DECLPROC recv_internal
DECLPROC recv_external
DECLPROC dnsdictlookup
123660 DECLMETHOD dnsresolve
87450 DECLMETHOD getexpirationx
110574 DECLMETHOD getexpiration
67418 DECLMETHOD getstdperiod
109522 DECLMETHOD getppr
108994 DECLMETHOD getppc
113123 DECLMETHOD getppb
113304 DECLMETHOD calcprice
85700 DECLMETHOD calcregprice
DECLGLOBVAR query_info
load_data PROCREF:<{
//
c4 PUSH // _1
CTOS // cs
LDREF // _3 cs
LDDICT // _3 _5 cs
LDDICT // _3 _5 _7 cs
30 LDU // _3 _5 _7 _10 cs
LDGRAMS // _3 _5 _7 _10 _13 cs
LDGRAMS // _3 _5 _7 _10 _13 _15 cs
LDGRAMS // _3 _5 _7 _10 _13 _15 _17 cs
4 -ROLL // _3 _5 _7 cs _10 _13 _15 _17
4 TUPLE // _3 _5 _7 cs _9
SWAP // _3 _5 _7 _9 cs
32 LDU // _3 _5 _7 _9 _19 cs
32 LDU // _3 _5 _7 _9 _19 _42 _41
DROP // _3 _5 _7 _9 _19 _22
}>
load_prices PROCREF:<{
//
c4 PUSH // _1
CTOS // cs
LDREF // _19 _18
NIP // cs
LDDICT // _21 _20
NIP // cs
LDDICT // _23 _22
NIP // cs
30 LDU // _9 cs
LDGRAMS // _9 _12 cs
LDGRAMS // _9 _12 _14 cs
LDGRAMS // _9 _12 _14 _31 _30
DROP // _9 _12 _14 _16
}>
store_data PROC:<{
// ctl dd gc prices nhk lhk
s0 s2 XCHG // ctl dd gc lhk nhk prices
4 UNTUPLE // ctl dd gc lhk nhk sp ppr ppc ppb
s0 s8 XCHG
NEWC // ppb dd gc lhk nhk sp ppr ppc ctl _11
STREF // ppb dd gc lhk nhk sp ppr ppc _12
s1 s7 XCHG // ppb ppc gc lhk nhk sp ppr dd _12
STDICT // ppb ppc gc lhk nhk sp ppr _13
s1 s5 XCHG // ppb ppc ppr lhk nhk sp gc _13
STDICT // ppb ppc ppr lhk nhk sp _14
30 STU // ppb ppc ppr lhk nhk _16
s0 s3 XCHG2 // ppb ppc nhk lhk _16 ppr
STGRAMS // ppb ppc nhk lhk _17
s0 s3 XCHG2 // ppb lhk nhk _17 ppc
STGRAMS // ppb lhk nhk _18
s0 s3 XCHG2 // nhk lhk _18 ppb
STGRAMS // nhk lhk _19
s1 s2 XCHG // lhk nhk _19
32 STU // lhk _21
32 STU // _23
ENDC // _24
c4 POP
}>
send_message PROC:<{
// addr tag query_id body grams mode
0 PUSHINT // addr tag query_id body grams mode _7=0
24 PUSHINT // addr tag query_id body grams mode _7=0 _8=24
NEWC // addr tag query_id body grams mode _7=0 _8=24 _9
6 STU // addr tag query_id body grams mode _7=0 _11
s0 s7 XCHG2 // _7=0 tag query_id body grams mode _11 addr
STSLICER // _7=0 tag query_id body grams mode _12
ROT // _7=0 tag query_id body mode _12 grams
STGRAMS // _7=0 tag query_id body mode _13
s1 s5 XCHG // mode tag query_id body _7=0 _13
107 STU // mode tag query_id body _27
s1 s3 XCHG // mode body query_id tag _27
32 STU // mode body query_id _29
64 STU // mode body msg
OVER // mode body msg body
-1 GTINT // mode body msg _33
IF:<{ // mode body msg
32 STU // mode msg
}>ELSE<{
NIP // mode msg
}>
ENDC // mode _37
SWAP // _37 mode
SENDRAWMSG
}>
send_error PROC:<{
// error_code
query_info GETGLOB
UNTRIPLE // error_code addr query_id op
s2 s3 XCHG
0 PUSHINT
64 PUSHINT // addr error_code query_id op _5=0 _6=64
send_message CALLDICT
}>
send_ok PROC:<{
// price
4 PUSHINT // price _1=4
RAWRESERVE
query_info GETGLOB
UNTRIPLE // addr query_id op
4016791929 PUSHINT // addr query_id op _7=4016791929
-ROT
0 PUSHINT
7 PUSHPOW2 // addr _7=4016791929 query_id op _8=0 _9=128
send_message CALLDICT
}>
housekeeping PROC:<{
// ctl dd gc prices nhk lhk max_steps
NOW // ctl dd gc prices nhk lhk max_steps n
s2 PUSH // ctl dd gc prices nhk lhk max_steps n lhk
60 ADDCONST // ctl dd gc prices nhk lhk max_steps n _10
s4 s(-1) PUXC // ctl dd gc prices nhk lhk max_steps n nhk _10
MAX // ctl dd gc prices nhk lhk max_steps n _11
s1 s(-1) PUXC // ctl dd gc prices nhk lhk max_steps n n _11
LESS // ctl dd gc prices nhk lhk max_steps n _12
IFJMP:<{ // ctl dd gc prices nhk lhk max_steps n
2DROP // ctl dd gc prices nhk lhk
store_data CALLDICT
}> // ctl dd gc prices nhk lhk max_steps n
s2 POP // ctl dd gc prices nhk n max_steps
s4 PUSH
8 PUSHPOW2 // ctl dd gc prices nhk n max_steps gc _17=256
DICTUMIN
NULLSWAPIFNOT2 // ctl dd gc prices nhk n max_steps _63 _62 _64
s2 POP // ctl dd gc prices nhk n max_steps found? mkey
WHILE:<{
s1 s2 XCPU // ctl dd gc prices nhk n max_steps mkey found? max_steps
AND // ctl dd gc prices nhk n max_steps mkey _19
}>DO<{ // ctl dd gc prices nhk n max_steps mkey
s3 POP // ctl dd gc prices mkey n max_steps
s2 PUSH // ctl dd gc prices mkey n max_steps mkey
224 RSHIFT# // ctl dd gc prices mkey n max_steps nhk
s0 s2 PUSH2 // ctl dd gc prices mkey n max_steps nhk nhk n
LESS // ctl dd gc prices mkey n max_steps nhk _24
IF:<{ // ctl dd gc prices mkey n max_steps nhk
DROP // ctl dd gc prices mkey n max_steps
s2 PUSH // ctl dd gc prices mkey n max_steps mkey
224 MODPOW2# // ctl dd gc prices mkey n max_steps key
s0 s6 PUSH2
224 PUSHINT // ctl dd gc prices mkey n max_steps key key dd _35
DICTUGET
NULLSWAPIFNOT // ctl dd gc prices mkey n max_steps key val found?
IF:<{ // ctl dd gc prices mkey n max_steps key val
32 PLDU // ctl dd gc prices mkey n max_steps key exp
s3 PUSH // ctl dd gc prices mkey n max_steps key exp n
LEQ // ctl dd gc prices mkey n max_steps key _40
IF:<{ // ctl dd gc prices mkey n max_steps key
s0 s6 XCHG2
224 PUSHINT // ctl max_steps gc prices mkey n key dd _44
DICTUDEL // ctl max_steps gc prices mkey n _67 _68
DROP // ctl max_steps gc prices mkey n dd
s0 s5 XCHG // ctl dd gc prices mkey n max_steps
}>ELSE<{
DROP // ctl dd gc prices mkey n max_steps
}>
}>ELSE<{
2DROP // ctl dd gc prices mkey n max_steps
}>
s2 s4 XCHG2
8 PUSHPOW2 // ctl dd max_steps prices n mkey gc _47=256
DICTUDEL // ctl dd max_steps prices n _69 _70
DROP // ctl dd max_steps prices n gc
DUP
8 PUSHPOW2 // ctl dd max_steps prices n gc gc _50=256
DICTUMIN
NULLSWAPIFNOT2 // ctl dd max_steps prices n gc _72 _71 _73
s2 POP // ctl dd max_steps prices n gc found? mkey
OVER // ctl dd max_steps prices n gc found? mkey found?
IF:<{ // ctl dd max_steps prices n gc found? mkey
DUP // ctl dd max_steps prices n gc found? mkey mkey
224 RSHIFT# // ctl dd max_steps prices n gc found? mkey _52
}>ELSE<{ // ctl dd max_steps prices n gc found? mkey
32 PUSHPOW2DEC // ctl dd max_steps prices n gc found? mkey _52=4294967295
}> // ctl dd max_steps prices n gc found? mkey nhk
s0 s6 XCHG // ctl dd nhk prices n gc found? mkey max_steps
DEC // ctl dd nhk prices n gc found? mkey max_steps
}>ELSE<{ // ctl dd gc prices mkey n max_steps nhk
s5 s1 s5 XCHG3
s0 s3 XCHG
FALSE
s0 s2 XCHG // ctl dd nhk prices n gc found? mkey max_steps
}>
s3 s6 XCHG
s3 s4 XCHG
-ROT // ctl dd gc prices nhk n max_steps found? mkey
}> // ctl dd gc prices nhk n max_steps mkey
2DROP // ctl dd gc prices nhk n
store_data CALLDICT
}>
calcprice_internal PROCREF:<{
// domain data ppc ppb
s0 s2 XCHG
100 PUSHINT // domain ppb ppc data _7=100
CDATASIZE // domain ppb ppc _24 _25 _26
s2 POP // domain ppb ppc refs bits
s0 s4 XCHG // bits ppb ppc refs domain
SBITS // bits ppb ppc refs _9
1 LSHIFT# // bits ppb ppc refs _11
192 PUSHINT // bits ppb ppc refs _11 _16
ADD // bits ppb ppc refs _17
s1 s4 XCHG // refs ppb ppc bits _17
ADD // refs ppb ppc bits
s0 s3 XCHG // bits ppb ppc refs
2 ADDCONST // bits ppb ppc _20
MUL // bits ppb _21
s0 s2 XCHG // _21 ppb bits
MUL // _21 _22
ADD // _23
}>
check_owner PROCREF:<{
// cat_table owner_info src_wc src_addr strict
s0 s4 XCHG // strict owner_info src_wc src_addr cat_table
ISNULL // strict owner_info src_wc src_addr _5
s4 s(-1) PUXC // strict owner_info src_wc src_addr strict _5
AND // strict owner_info src_wc src_addr _6
IFJMP:<{ // strict owner_info src_wc src_addr
4 BLKDROP //
4000281702 PUSHINT // _7=4000281702
}> // strict owner_info src_wc src_addr
s2 PUSH // strict owner_info src_wc src_addr owner_info
ISNULL // strict owner_info src_wc src_addr _8
IFJMP:<{ // strict owner_info src_wc src_addr
3 BLKDROP // strict
4000263474 PUSHINT // strict _9=4000263474
AND // _10
}> // strict owner_info src_wc src_addr
s3 POP // src_addr owner_info src_wc
3798033458 PUSHINT // src_addr owner_info src_wc ERR_BAD2=3798033458
s0 s2 XCHG // src_addr ERR_BAD2=3798033458 src_wc owner_info
CTOS // src_addr ERR_BAD2=3798033458 src_wc sown
DUP // src_addr ERR_BAD2=3798033458 src_wc sown sown
SBITS // src_addr ERR_BAD2=3798033458 src_wc sown _15
283 PUSHINT // src_addr ERR_BAD2=3798033458 src_wc sown _15 _22
LESS // src_addr ERR_BAD2=3798033458 src_wc sown _23
IFJMP:<{ // src_addr ERR_BAD2=3798033458 src_wc sown
s2 s3 XCHG
3 BLKDROP // ERR_BAD2=3798033458
}> // src_addr ERR_BAD2=3798033458 src_wc sown
19 LDU // src_addr ERR_BAD2=3798033458 src_wc _24 sown
SWAP
327324 PUSHINT // src_addr ERR_BAD2=3798033458 src_wc sown _24 _33
NEQ // src_addr ERR_BAD2=3798033458 src_wc sown _34
IFJMP:<{ // src_addr ERR_BAD2=3798033458 src_wc sown
s2 s3 XCHG
3 BLKDROP // ERR_BAD2=3798033458
}> // src_addr ERR_BAD2=3798033458 src_wc sown
1 2 BLKDROP2 // src_addr src_wc sown
8 LDI // src_addr src_wc _37 sown
256 PLDU // src_addr src_wc owner_wc owner_addr
s0 s2 XCHG // src_addr owner_addr owner_wc src_wc
NEQ // src_addr owner_addr _42
s0 s2 XCHG // _42 owner_addr src_addr
NEQ // _42 _43
OR // _44
IFJMP:<{ //
4000282478 PUSHINT // _45=4000282478
}> //
0 PUSHINT // _46=0
}>
perform_ctl_op PROCREF:<{
// op src_wc src_addr in_msg
load_data INLINECALLDICT // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk
s5 PUSH // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk ctl
CTOS // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk cs
8 LDI // op src_wc src_addr in_msg ctl domdata gc prices nhk lhk _13 cs
s0 s10 XCHG // op cs src_addr in_msg ctl domdata gc prices nhk lhk _13 src_wc
NEQ // op cs src_addr in_msg ctl domdata gc prices nhk lhk _16
s0 s9 XCHG // op _16 src_addr in_msg ctl domdata gc prices nhk lhk cs
256 LDU // op _16 src_addr in_msg ctl domdata gc prices nhk lhk _83 _82
DROP // op _16 src_addr in_msg ctl domdata gc prices nhk lhk _17
s0 s8 XCHG2 // op _16 lhk in_msg ctl domdata gc prices nhk _17 src_addr
NEQ // op _16 lhk in_msg ctl domdata gc prices nhk _20
s1 s8 XCHG // op nhk lhk in_msg ctl domdata gc prices _16 _20
OR // op nhk lhk in_msg ctl domdata gc prices _21
IFJMP:<{ // op nhk lhk in_msg ctl domdata gc prices
8 BLKDROP //
4000282478 PUSHINT // _22=4000282478
send_error CALLDICT
}> // op nhk lhk in_msg ctl domdata gc prices
s0 s7 XCHG
1130909810 PUSHINT // prices nhk lhk in_msg ctl domdata gc op _24=1130909810
EQUAL // prices nhk lhk in_msg ctl domdata gc _25
IFJMP:<{ // prices nhk lhk in_msg ctl domdata gc
s6 POP // gc nhk lhk in_msg ctl domdata
s0 s2 XCHG // gc nhk lhk domdata ctl in_msg
32 LDU // gc nhk lhk domdata ctl _30 in_msg
LDGRAMS // gc nhk lhk domdata ctl _30 _33 in_msg
LDGRAMS // gc nhk lhk domdata ctl _30 _33 _35 in_msg
LDGRAMS // gc nhk lhk domdata ctl stdper ppr ppc ppb in_msg
ENDS
4 TUPLE // gc nhk lhk domdata ctl _40
s0 s4 s4 XCHG3
s0 s5 XCHG
s0 s3 XCHG // ctl domdata gc _40 nhk lhk
store_data CALLDICT
0 PUSHINT // _42=0
send_ok CALLDICT
}> // prices nhk lhk in_msg ctl domdata gc
s4 POP // prices nhk gc in_msg ctl domdata
query_info GETGLOB
UNTRIPLE // prices nhk gc in_msg ctl domdata addr query_id op
DUP
1128555884 PUSHINT // prices nhk gc in_msg ctl domdata addr query_id op op _48=1128555884
EQUAL // prices nhk gc in_msg ctl domdata addr query_id op _49
IFJMP:<{ // prices nhk gc in_msg ctl domdata addr query_id op
s5 POP // prices nhk gc op ctl domdata addr query_id
s2 PUSH // prices nhk gc op ctl domdata addr query_id domdata
ISNULL // prices nhk gc op ctl domdata addr query_id _50
IFNOT:<{ // prices nhk gc op ctl domdata addr query_id
s3 s4 XCHG
s2 s3 XCHG
s5 s7 s6 XCHG3
1 PUSHINT
-1 PUSHINT // addr query_id op ctl domdata gc prices nhk _51=1 _52=-1
housekeeping CALLDICT
-ROT // op addr query_id
}>ELSE<{
s4 s7 XCHG
5 2 BLKDROP2 // op addr query_id
}>
load_data INLINECALLDICT // op addr query_id _95 _96 _97 _98 _99 _100
s4 s5 XCHG
5 BLKDROP // op addr query_id domdata
ISNULL // op addr query_id _55
IFNOTJMP:<{ // op addr query_id
3 BLKDROP //
4000605549 PUSHINT // _56=4000605549
send_error CALLDICT
}> // op addr query_id
4016791929 PUSHINT // op addr query_id _58=4016791929
s0 s1 s3 XCHG3
0 PUSHINT
160 PUSHINT // addr _58=4016791929 query_id op _59=0 _62
send_message CALLDICT
}> // prices nhk gc in_msg ctl domdata addr query_id op
s3 POP
s3 POP
s4 POP
s4 POP
s4 POP // query_id op addr in_msg
s2 PUSH
1415670629 PUSHINT // query_id op addr in_msg op _64=1415670629
EQUAL // query_id op addr in_msg _65
IFJMP:<{ // query_id op addr in_msg
LDGRAMS // query_id op addr _102 _101
DROP // query_id op addr amount
s1 s3 XCHG
4016791929 PUSHINT
s3 s3 XCHG2
64 PUSHINT // addr _69=4016791929 query_id op amount _70=64
send_message CALLDICT
}> // query_id op addr in_msg
4 BLKDROP //
32 PUSHPOW2DEC // _72=4294967295
send_error CALLDICT
}>
recv_internal PROC:<{
// msg_value in_msg_cell in_msg
DUP // msg_value in_msg_cell in_msg in_msg
SBITS // msg_value in_msg_cell in_msg _3
32 LESSINT // msg_value in_msg_cell in_msg _5
IFJMP:<{ // msg_value in_msg_cell in_msg
3 BLKDROP //
}> // msg_value in_msg_cell in_msg
SWAP // msg_value in_msg in_msg_cell
CTOS // msg_value in_msg cs
4 LDU // msg_value in_msg flags cs
SWAP
1 PUSHINT // msg_value in_msg cs flags _12=1
AND // msg_value in_msg cs _13
IFJMP:<{ // msg_value in_msg cs
3 BLKDROP //
}> // msg_value in_msg cs
LDMSGADDR // msg_value in_msg _327 _326
DROP // msg_value in_msg s_addr
DUP // msg_value in_msg s_addr s_addr
REWRITESTDADDR // msg_value in_msg s_addr src_wc src_addr
s0 s3 XCHG // msg_value src_addr s_addr src_wc in_msg
32 LDU // msg_value src_addr s_addr src_wc op in_msg
OVER // msg_value src_addr s_addr src_wc op in_msg op
IFNOTJMP:<{ // msg_value src_addr s_addr src_wc op in_msg
6 BLKDROP //
}> // msg_value src_addr s_addr src_wc op in_msg
0 PUSHINT // msg_value src_addr s_addr src_wc op in_msg query_id=0
OVER // msg_value src_addr s_addr src_wc op in_msg query_id=0 in_msg
SBITS // msg_value src_addr s_addr src_wc op in_msg query_id=0 _26
63 GTINT // msg_value src_addr s_addr src_wc op in_msg query_id=0 _28
IF:<{ // msg_value src_addr s_addr src_wc op in_msg query_id=0
DROP // msg_value src_addr s_addr src_wc op in_msg
64 LDU // msg_value src_addr s_addr src_wc op query_id in_msg
SWAP // msg_value src_addr s_addr src_wc op in_msg query_id
}> // msg_value src_addr s_addr src_wc op in_msg query_id
s4 s0 s2 XC2PU // msg_value src_addr in_msg src_wc op s_addr query_id op
TRIPLE
query_info SETGLOB
DUP
31 PUSHPOW2 // msg_value src_addr in_msg src_wc op op _34
AND // msg_value src_addr in_msg src_wc op _35
IFJMP:<{ // msg_value src_addr in_msg src_wc op
5 BLKDROP //
}> // msg_value src_addr in_msg src_wc op
DUP // msg_value src_addr in_msg src_wc op op
24 RSHIFT# // msg_value src_addr in_msg src_wc op _37
67 EQINT // msg_value src_addr in_msg src_wc op _39
IFJMP:<{ // msg_value src_addr in_msg src_wc op
s4 POP // op src_addr in_msg src_wc
-ROT // op src_wc src_addr in_msg
perform_ctl_op INLINECALLDICT
}> // msg_value src_addr in_msg src_wc op
DUP
1919248228 PUSHINT // msg_value src_addr in_msg src_wc op op _42=1919248228
EQUAL // msg_value src_addr in_msg src_wc op _45
OVER
1886547820 PUSHINT // msg_value src_addr in_msg src_wc op _45 op _46=1886547820
EQUAL // msg_value src_addr in_msg src_wc op _45 _47
1 LSHIFT# // msg_value src_addr in_msg src_wc op _45 _49
ADD // msg_value src_addr in_msg src_wc op _50
OVER
1970300004 PUSHINT // msg_value src_addr in_msg src_wc op _50 op _51=1970300004
EQUAL // msg_value src_addr in_msg src_wc op _50 _52
2 LSHIFT# // msg_value src_addr in_msg src_wc op _50 _54
ADD // msg_value src_addr in_msg src_wc op _55
SWAP
1735354211 PUSHINT // msg_value src_addr in_msg src_wc _55 op _56=1735354211
EQUAL // msg_value src_addr in_msg src_wc _55 _57
3 LSHIFT# // msg_value src_addr in_msg src_wc _55 _59
ADD // msg_value src_addr in_msg src_wc qt
DUP // msg_value src_addr in_msg src_wc qt qt
IFNOTJMP:<{ // msg_value src_addr in_msg src_wc qt
5 BLKDROP //
32 PUSHPOW2DEC // _61=4294967295
send_error CALLDICT
}> // msg_value src_addr in_msg src_wc qt
NEGATE // msg_value src_addr in_msg src_wc qt
load_data INLINECALLDICT // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk
s6 PUSH // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk qt
8 EQINT // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk _72
IFJMP:<{ // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk
DROP
s5 POP
s5 POP
s6 POP
s6 POP // domdata gc in_msg prices nhk ctl
s0 s3 XCHG // domdata gc ctl prices nhk in_msg
32 LDI // domdata gc ctl prices nhk _341 _340
DROP // domdata gc ctl prices nhk max_steps
s3 s5 XCHG
s3 s4 XCHG
1 PUSHINT
SWAP // ctl domdata gc prices nhk _77=1 max_steps
housekeeping CALLDICT
4016791929 PUSHINT // _79=4016791929
send_error CALLDICT
}> // msg_value src_addr in_msg src_wc qt ctl domdata gc prices nhk lhk
s0 s8 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg
LDOPTREF // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg
OVER // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg domain_cell
ISNULL // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg _88
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg
NIP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg
6 LDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk bytes in_msg
OVER // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk bytes in_msg bytes
0 EQINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk bytes in_msg fail
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail in_msg bytes
3 LSHIFT# // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail in_msg _97
LDSLICEX // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
}>ELSE<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk domain_cell in_msg
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain_cell
CTOS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
DUP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain domain
SBITREFS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain bits refs
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs bits
-8 ADDCONST // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs _104
-121 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs _104 _107
AND // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain refs _108
OR // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain fail
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
}>
s2 PUSH // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg fail
IFNOT:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
s2 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
DUP
8 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain domain _110=8
SDCUTLAST // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain _111
8 PLDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain fail
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk fail domain in_msg
s0 s2 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain fail
IFJMP:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
12 BLKDROP //
4000275504 PUSHINT // _114=4000275504
send_error CALLDICT
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain
NOW // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n
PUSHNULL // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n _120
DUP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info
0 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info _124=0
s0 s0 s4 PUSH3 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail
DUP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail tail
SBITS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail _126
3 RSHIFTC# // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key=0 zeros=0 exp=0 tail _128
REPEAT:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
PUSHNULL
s6 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
8 LDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp _131 tail
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail _131
0 EQINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail z
s3 s3 XCPU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key z exp tail zeros z
SUB // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key z exp tail zeros
s0 s3 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail z
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
s3 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp
s2 PUSH // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp tail
SBITS // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp _137
s7 s(-1) PUXC // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp domain _137
SDSKIPLAST // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp _138
SHA256U // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp _139
32 RSHIFT# // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key
s0 s12 PUSH2
224 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key key domdata _146
DICTUGET
NULLSWAPIFNOT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key val found?
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key val
1 2 BLKDROP2 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key val
32 LDU // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val
s1 s7 PUSH2 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val exp n
GEQ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val _151
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp val
LDREF // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cat_table val
ENDS
0 PUSHINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cat_table _158=0
SWAP
8 PUSHPOW2 // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp _158=0 cat_table _159=256
DICTUGETREF // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cown ok
IF:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp cown
s5 POP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp
}>ELSE<{
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp
}>
}>ELSE<{
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros key exp
}>
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key
}>ELSE<{
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info tail zeros exp key
}>
s0 s3 XCHG // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp tail
}>
DROP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key zeros exp
SWAP // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp zeros
4 GTINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp _162
IFJMP:<{ // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp
15 BLKDROP
2DROP //
4017511472 PUSHINT // _163=4017511472
send_error CALLDICT
}> // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp
s12 PUSH // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp qt
1 NEQINT // msg_value src_addr lhk src_wc qt ctl domdata gc prices nhk in_msg domain n cat_table owner_info key exp _167
s4 PUSH
s0 s4 XCHG
s15 s1 s3 XCHG3
s0 17 s() XCHG
SWAP // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table cat_table owner_info src_wc src_addr _167
check_owner INLINECALLDICT // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err
DUP // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err err
IFJMP:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err
14 1 BLKDROP2 // err
send_error CALLDICT
}> // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table err
DROP // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table
s9 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table qt
2 NEQINT // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table _173
IF:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table
s0 s3 XCHG // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n in_msg
LDREF // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n _361 _360
DROP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
DUP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data data
DICTEMPTY // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _176
IFNOT:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
0 PUSHINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _179=0
OVER
8 PUSHPOW2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _179=0 data _180=256
DICTUGETREF // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data oinfo ok
IF:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data oinfo
CTOS // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs
DUP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs cs
SBITS // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs _185
283 PUSHINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs _185 _192
GEQ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data cs _193
31 THROWIFNOT
19 PLDU // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _197
327324 PUSHINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _197 _202
EQUAL // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _203
31 THROWIFNOT
}>ELSE<{
DROP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
}>
DUP
8 PUSHPOW2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data data _208=256
DICTUMIN
NULLSWAPIFNOT2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _365 _364 _366
2 1 BLKDROP2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok
OVER
8 PUSHPOW2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok data _213=256
DICTUMAX
NULLSWAPIFNOT2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok _368 _367 _369
2 1 BLKDROP2 // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data minok maxok
AND // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data _216
31 THROWIFNOT
}> // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
}>ELSE<{ // msg_value key lhk exp qt ctl domdata gc prices nhk in_msg domain n cat_table
s3 POP // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n
s2 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data
}>
s5 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data prices
4 UNTUPLE // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb
s3 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb stdper
IFNOTJMP:<{ // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb
15 BLKDROP
3 BLKDROP //
3545187910 PUSHINT // _223=3545187910
send_error CALLDICT
}> // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table domain n data stdper ppr ppc ppb
s4 PUSH
s3 s7 XCHG
-ROT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper domain data ppc ppb
calcprice_internal INLINECALLDICT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper _226
s11 PUSH // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper _226 qt
4 NEQINT // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table ppr n data stdper _226 _228
s1 s5 XCHG // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table _226 n data stdper ppr _228
AND // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table _226 n data stdper _229
s1 s4 XCHG // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _226 _229
ADD // msg_value key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data price
s0 s14 XCHG
30 PUSHPOW2 // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data msg_value _233
SUB // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _234
s14 PUSH // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _234 price
LESS // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _235
IFJMP:<{ // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
14 BLKDROP //
3883023472 PUSHINT // _236=3883023472
send_error CALLDICT
}> // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s9 PUSH // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data qt
2 EQINT // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _243
IFJMP:<{ // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s3 POP
s8 POP // price key lhk exp n ctl domdata gc prices nhk data stdper
s7 s7 XCPU // price key lhk exp stdper ctl domdata gc prices nhk data n stdper
ADD // price key lhk exp stdper ctl domdata gc prices nhk data _244
s8 s(-1) PUXC // price key lhk exp stdper ctl domdata gc prices nhk data exp _244
GREATER // price key lhk exp stdper ctl domdata gc prices nhk data _245
IFJMP:<{ // price key lhk exp stdper ctl domdata gc prices nhk data
11 BLKDROP //
4083511919 PUSHINT // _246=4083511919
send_error CALLDICT
}> // price key lhk exp stdper ctl domdata gc prices nhk data
s7 s6 PUSH2 // price key lhk exp stdper ctl domdata gc prices nhk data exp stdper
ADD // price key lhk exp stdper ctl domdata gc prices nhk data _249
NEWC // price key lhk exp stdper ctl domdata gc prices nhk data _249 _250
32 STU // price key lhk exp stdper ctl domdata gc prices nhk data _252
STREF // price key lhk exp stdper ctl domdata gc prices nhk _253
s0 s9 s4 XCPUXC
224 PUSHINT // price key lhk exp stdper ctl nhk gc prices _253 key domdata _256
DICTUSETB // price key lhk exp stdper ctl nhk gc prices domdata
s0 s6 XCHG // price key lhk domdata stdper ctl nhk gc prices exp
224 LSHIFT# // price key lhk domdata stdper ctl nhk gc prices _262
s0 s8 XCHG2 // price prices lhk domdata stdper ctl nhk gc _262 key
ADD // price prices lhk domdata stdper ctl nhk gc gckeyO
s0 s4 XCHG // price prices lhk domdata gckeyO ctl nhk gc stdper
224 LSHIFT# // price prices lhk domdata gckeyO ctl nhk gc _268
s4 s(-1) PUXC // price prices lhk domdata gckeyO ctl nhk gc gckeyO _268
ADD // price prices lhk domdata gckeyO ctl nhk gc gckeyN
s4 s4 XCHG2
8 PUSHPOW2 // price prices lhk domdata gckeyN ctl nhk gckeyO gc _271=256
DICTUDEL // price prices lhk domdata gckeyN ctl nhk _376 _377
DROP // price prices lhk domdata gckeyN ctl nhk gc
NEWC // price prices lhk domdata gckeyN ctl nhk gc _274
s0 s4 s4 XCHG3
8 PUSHPOW2 // price prices lhk domdata nhk ctl _274 gckeyN gc _275=256
DICTUSETB // price prices lhk domdata nhk ctl gc
s0 s3 XCHG
s5 s5 s4 XCHG3
1 PUSHINT // price ctl domdata gc prices nhk lhk _277=1
housekeeping CALLDICT
send_ok CALLDICT
}> // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s9 PUSH // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data qt
1 EQINT // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data _281
IFJMP:<{ // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
s9 POP
s9 POP // price key lhk n data ctl domdata gc prices nhk cat_table stdper
SWAP // price key lhk n data ctl domdata gc prices nhk stdper cat_table
ISNULL // price key lhk n data ctl domdata gc prices nhk stdper _282
IFNOTJMP:<{ // price key lhk n data ctl domdata gc prices nhk stdper
11 BLKDROP //
3781980773 PUSHINT // _283=3781980773
send_error CALLDICT
}> // price key lhk n data ctl domdata gc prices nhk stdper
s1 s7 XCHG // price key lhk nhk data ctl domdata gc prices n stdper
ADD // price key lhk nhk data ctl domdata gc prices expires_at
DUP
NEWC // price key lhk nhk data ctl domdata gc prices expires_at expires_at _288
32 STU // price key lhk nhk data ctl domdata gc prices expires_at _290
s1 s6 XCHG // price key lhk nhk expires_at ctl domdata gc prices data _290
STREF // price key lhk nhk expires_at ctl domdata gc prices _291
s0 s8 s3 XCPUXC
224 PUSHINT // price key lhk nhk expires_at ctl prices gc _291 key domdata _294
DICTUSETB // price key lhk nhk expires_at ctl prices gc domdata
s4 PUSH // price key lhk nhk expires_at ctl prices gc domdata expires_at
224 LSHIFT# // price key lhk nhk expires_at ctl prices gc domdata _300
s0 s8 XCHG2 // price domdata lhk nhk expires_at ctl prices gc _300 key
OR // price domdata lhk nhk expires_at ctl prices gc gckey
NEWC // price domdata lhk nhk expires_at ctl prices gc gckey _303
s0 s2 XCHG
8 PUSHPOW2 // price domdata lhk nhk expires_at ctl prices _303 gckey gc _304=256
DICTUSETB // price domdata lhk nhk expires_at ctl prices gc
s4 s3 XCHG2 // price domdata lhk prices gc ctl nhk expires_at
MIN // price domdata lhk prices gc ctl _306
s1 s5 XCHG
s3 s0 s4 XCHG3
1 PUSHINT // price ctl domdata gc prices _306 lhk _307=1
housekeeping CALLDICT
send_ok CALLDICT
}> // price key lhk exp qt ctl domdata gc prices nhk cat_table stdper n data
3 1 BLKDROP2 // price key lhk exp qt ctl domdata gc prices nhk data
s0 s6 XCHG // price key lhk exp data ctl domdata gc prices nhk qt
4 EQINT // price key lhk exp data ctl domdata gc prices nhk _311
IFJMP:<{ // price key lhk exp data ctl domdata gc prices nhk
s0 s6 XCHG
NEWC // price key lhk nhk data ctl domdata gc prices exp _313
32 STU // price key lhk nhk data ctl domdata gc prices _315
s1 s5 XCHG // price key lhk nhk prices ctl domdata gc data _315
STREF // price key lhk nhk prices ctl domdata gc _316
s7 s2 XCHG2
224 PUSHINT // price gc lhk nhk prices ctl _316 key domdata _319
DICTUSETB // price gc lhk nhk prices ctl domdata
s5 s4 XCHG2
s1 s3 XCHG
1 PUSHINT // price ctl domdata gc prices nhk lhk _321=1
housekeeping CALLDICT
send_ok CALLDICT
}> // price key lhk exp data ctl domdata gc prices nhk
10 BLKDROP //
}>
recv_external PROC:<{
// in_msg
DROP //
load_data INLINECALLDICT // _12 _13 _14 _15 _16 _17
NIP // ctl dd gc prices lhk
IFNOTJMP:<{ // ctl dd gc prices
ACCEPT
32 PUSHPOW2DEC // ctl dd gc prices _9=4294967295
NOW // ctl dd gc prices _9=4294967295 _10
store_data CALLDICT
}> // ctl dd gc prices
4 BLKDROP //
}>
dnsdictlookup PROCREF:<{
// domain nowtime
OVER // domain nowtime domain
SBITREFS // domain nowtime bits refs
OVER
7 PUSHINT // domain nowtime bits refs bits _6=7
AND // domain nowtime bits refs _7
OR // domain nowtime bits _8
30 THROWIF
DUP // domain nowtime bits bits
IFNOT:<{ // domain nowtime bits
30 THROW
}> // domain nowtime bits
s2 PUSH
8 PUSHINT // domain nowtime bits domain _13=8
SDCUTLAST // domain nowtime bits _14
8 PLDU // domain nowtime bits domain_last_byte
IF:<{ // domain nowtime bits
0 PUSHINT // domain nowtime bits _17=0
NEWC // domain nowtime bits _17=0 _18
s0 s4 XCHG2 // _17=0 nowtime bits _18 domain
STSLICER // _17=0 nowtime bits _19
s1 s3 XCHG // bits nowtime _17=0 _19
8 STU // bits nowtime _21
ENDC // bits nowtime _22
CTOS // bits nowtime domain
s0 s2 XCHG // domain nowtime bits
8 ADDCONST // domain nowtime bits
}> // domain nowtime bits
DUP // domain nowtime bits bits
8 EQINT // domain nowtime bits _27
IFJMP:<{ // domain nowtime bits
3 BLKDROP //
0 PUSHINT // _28=0
PUSHNULL // _28=0 _29
8 PUSHINT // _28=0 _29 _30=8
PUSHNULL // _28=0 _29 _30=8 _31
}> // domain nowtime bits
s2 PUSH // domain nowtime bits domain
8 PLDU // domain nowtime bits domain_first_byte
0 EQINT // domain nowtime bits _36
IF:<{ // domain nowtime bits
s0 s2 XCHG // bits nowtime domain
8 LDU // bits nowtime _95 _94
NIP // bits nowtime domain
s0 s2 XCHG // domain nowtime bits
-8 ADDCONST // domain nowtime bits
}> // domain nowtime bits
c4 PUSH // domain nowtime bits _43
CTOS // domain nowtime bits ds
LDREF // domain nowtime bits _97 _96
NIP // domain nowtime bits ds
LDDICT // domain nowtime bits _99 _98
DROP // domain nowtime bits root
PUSHNULL // domain nowtime bits root val
-1 PUSHINT // domain nowtime bits root val tail_bits=-1
s5 PUSH // domain nowtime bits root val tail_bits=-1 tail
s0 s4 XCHG // domain nowtime tail root val tail_bits=-1 bits
3 RSHIFT# // domain nowtime tail root val tail_bits=-1 _57
REPEAT:<{ // domain nowtime tail root val tail_bits
s0 s3 XCHG // domain nowtime tail_bits root val tail
8 LDU // domain nowtime tail_bits root val _58 tail
SWAP // domain nowtime tail_bits root val tail _58
0 EQINT // domain nowtime tail_bits root val tail _62
IF:<{ // domain nowtime tail_bits root val tail
DUP // domain nowtime tail_bits root val tail tail
SBITS // domain nowtime tail_bits root val tail _64
s6 s(-1) PUXC // domain nowtime tail_bits root val tail domain _64
SDSKIPLAST // domain nowtime tail_bits root val tail _65
SHA256U // domain nowtime tail_bits root val tail _66
32 RSHIFT# // domain nowtime tail_bits root val tail key
s3 PUSH
224 PUSHINT // domain nowtime tail_bits root val tail key root _73
DICTUGET
NULLSWAPIFNOT // domain nowtime tail_bits root val tail v found?
IF:<{ // domain nowtime tail_bits root val tail v
DUP // domain nowtime tail_bits root val tail v v
32 PLDU // domain nowtime tail_bits root val tail v _76
s6 PUSH // domain nowtime tail_bits root val tail v _76 nowtime
GEQ // domain nowtime tail_bits root val tail v _77
IF:<{ // domain nowtime tail_bits root val tail v
s2 POP
s3 POP // domain nowtime tail root val
s2 PUSH // domain nowtime tail root val tail
SBITS // domain nowtime tail root val tail_bits
s0 s3 XCHG // domain nowtime tail_bits root val tail
}>ELSE<{
DROP // domain nowtime tail_bits root val tail
}>
}>ELSE<{
DROP // domain nowtime tail_bits root val tail
}>
}> // domain nowtime tail_bits root val tail
s0 s3 XCHG // domain nowtime tail root val tail_bits
}>
2 2 BLKDROP2
s2 POP // domain tail_bits val
DUP // domain tail_bits val val
ISNULL // domain tail_bits val _79
IFJMP:<{ // domain tail_bits val
3 BLKDROP //
0 PUSHINT // _80=0
PUSHNULL // _80=0 _81
OVER // _80=0 _81 _82=0
PUSHNULL // _80=0 _81 _82=0 _83
}> // domain tail_bits val
32 LDU // domain tail_bits _84 val
LDREF // domain tail_bits _84 _107 _106
DROP // domain tail_bits _84 _87
s2 PUSH // domain tail_bits _84 _87 tail_bits
0 EQINT // domain tail_bits _84 _87 _90
s4 s3 XCHG2 // _87 _90 _84 domain tail_bits
SDSKIPLAST // _87 _90 _84 _91
s3 s3 s0 XCHG3 // _84 _87 _90 _91
}>
dnsresolve PROC:<{
// domain category
SWAP
NOW // category domain _6
dnsdictlookup INLINECALLDICT // category exp cat_table exact? pfx
s0 s3 XCHG // category pfx cat_table exact? exp
IFNOTJMP:<{ // category pfx cat_table exact?
3 1 BLKDROP2 // exact?
PUSHNULL // exact? _8
}> // category pfx cat_table exact?
IFNOT:<{ // category pfx cat_table
11732114750494247458678882651681748623800183221773167493832867265755123357695 PUSHINT
s3 POP // category=11732114750494247458678882651681748623800183221773167493832867265755123357695 pfx cat_table
}> // category pfx cat_table
SWAP // category cat_table pfx
SBITS // category cat_table pfx_bits
s2 PUSH // category cat_table pfx_bits category
IFJMP:<{ // category cat_table pfx_bits
-ROT
8 PUSHPOW2 // pfx_bits category cat_table _13=256
DICTUGETOPTREF // pfx_bits cat_found
}> // category cat_table pfx_bits
s2 POP // pfx_bits cat_table
}>
getexpirationx PROCINLINE:<{
// domain nowtime
dnsdictlookup INLINECALLDICT // _7 _8 _9 _10
3 BLKDROP // exp
}>
getexpiration PROC:<{
// domain
NOW // domain _1
getexpirationx INLINECALLDICT // _2
}>
getstdperiod PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
3 BLKDROP // stdper
}>
getppr PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
s2 s3 XCHG
3 BLKDROP // ppr
}>
getppc PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
s1 s3 XCHG
3 BLKDROP // ppc
}>
getppb PROC:<{
//
load_prices INLINECALLDICT // _5 _6 _7 _8
3 1 BLKDROP2 // ppb
}>
calcprice PROC:<{
// domain val
load_prices INLINECALLDICT // domain val _8 _9 _10 _11
2 2 BLKDROP2 // domain val ppc ppb
calcprice_internal INLINECALLDICT // _7
}>
calcregprice PROC:<{
// domain val
load_prices INLINECALLDICT // domain val _9 _10 _11 _12
s3 POP // domain val ppb ppr ppc
s3 s4 XCHG
s4 s0 s4 XCHG3 // ppr domain val ppc ppb
calcprice_internal INLINECALLDICT // ppr _7
ADD // _8
}>
}END>c

208
build/dns-utils.cell.fif

@ -0,0 +1,208 @@
"Asm.fif" include
"Asm.fif" include
// automatically generated from `contracts/dns-utils.fc` incl:`contracts/stdlib.fc`
PROGRAM{
DECLPROC zero_address
DECLPROC get_top_domain_bits
DECLPROC read_domain_from_comment
DECLPROC check_domain_string
DECLPROC get_min_price_config
DECLPROC get_min_price
zero_address PROC:<{
//
0 PUSHINT // _0=0
NEWC // _0=0 _1
2 STU // _3
ENDC // _4
CTOS // _5
}>
get_top_domain_bits PROC:<{
// domain
0 PUSHINT // domain i=0
UNTIL:<{
SWAP // i domain
8 LDU // i char domain
SWAP // i domain char
0 EQINT // i domain need_break
DUP // i domain need_break need_break
NOT // i domain need_break _11
IF:<{ // i domain need_break
s0 s2 XCHG // need_break domain i
8 ADDCONST // need_break domain i
s0 s2 XCHG // i domain need_break
}> // i domain need_break
s1 s2 XCHG // domain i need_break
}> // domain i
NIP // i
DUP // i i
0 EQINT // i _16
201 THROWIF
}>
read_domain_from_comment PROC:<{
// in_msg_body
NEWC // in_msg_body result
UNTIL:<{
OVER // in_msg_body result in_msg_body
SBITS // in_msg_body result _6
s1 s2 XCHG // result in_msg_body _6
LDSLICEX // result _5 in_msg_body
-ROT // in_msg_body result _5
STSLICER // in_msg_body result
OVER // in_msg_body result in_msg_body
SREFS // in_msg_body result refs_len
DUP // in_msg_body result refs_len refs_len
0 EQINT // in_msg_body result refs_len need_break
DUP // in_msg_body result refs_len need_break need_break
NOT // in_msg_body result refs_len need_break _13
IF:<{ // in_msg_body result refs_len need_break
SWAP // in_msg_body result need_break refs_len
1 EQINT // in_msg_body result need_break _16
202 THROWIFNOT
s0 s2 XCHG // need_break result in_msg_body
LDREF // need_break result _26 _25
DROP // need_break result _18
CTOS // need_break result in_msg_body
s0 s2 XCHG // in_msg_body result need_break
}>ELSE<{
NIP // in_msg_body result need_break
}>
}> // in_msg_body result
NIP // result
ENDC // _21
CTOS // _22
}>
check_domain_string PROC:<{
// domain
0 PUSHINT // domain i=0
OVER // domain i=0 domain
SBITS // domain i=0 len
UNTIL:<{
2DUP // domain i len i len
EQUAL // domain i len need_break
DUP // domain i len need_break need_break
NOT // domain i len need_break _8
IF:<{ // domain i len need_break
DROP // domain i len
s0 s2 XCHG // len i domain
8 LDU // len i char domain
OVER // len i char domain char
45 EQINT // len i char domain is_hyphen
s3 PUSH // len i char domain is_hyphen i
0 GTINT // len i char domain is_hyphen _18
AND // len i char domain _19
s4 PUSH // len i char domain _19 len
-8 ADDCONST // len i char domain _19 _21
s4 s(-1) PUXC // len i char domain _19 i _21
LESS // len i char domain _19 _22
AND // len i char domain _23
s2 PUSH // len i char domain _23 char
47 GTINT // len i char domain _23 _25
s3 PUSH // len i char domain _23 _25 char
58 LESSINT // len i char domain _23 _25 _27
AND // len i char domain _23 _28
OR // len i char domain _29
s2 PUSH // len i char domain _29 char
96 GTINT // len i char domain _29 _31
s0 s3 XCHG // len i _31 domain _29 char
123 LESSINT // len i _31 domain _29 _33
s1 s3 XCHG // len i _29 domain _31 _33
AND // len i _29 domain _34
s1 s2 XCHG // len i domain _29 _34
OR // len i domain valid_char
NOT // len i domain need_break
DUP // len i domain need_break need_break
NOT // len i domain need_break _37
IF:<{ // len i domain need_break
s0 s2 XCHG // len need_break domain i
8 ADDCONST // len need_break domain i
s0 s2 XCHG // len i domain need_break
}> // len i domain need_break
s1 s3 XCHG // domain i len need_break
}> // domain i len need_break
}> // domain i len
1 2 BLKDROP2 // i len
EQUAL // _40
}>
get_min_price_config PROC:<{
// domain_char_count
DUP // domain_char_count domain_char_count
4 EQINT // domain_char_count _2
IFJMP:<{ // domain_char_count
DROP //
1000 PUSHINT // _3=1000
100 PUSHINT // _3=1000 _4=100
}> // domain_char_count
DUP // domain_char_count domain_char_count
5 EQINT // domain_char_count _6
IFJMP:<{ // domain_char_count
DROP //
500 PUSHINT // _7=500
50 PUSHINT // _7=500 _8=50
}> // domain_char_count
DUP // domain_char_count domain_char_count
6 EQINT // domain_char_count _10
IFJMP:<{ // domain_char_count
DROP //
400 PUSHINT // _11=400
40 PUSHINT // _11=400 _12=40
}> // domain_char_count
DUP // domain_char_count domain_char_count
7 EQINT // domain_char_count _14
IFJMP:<{ // domain_char_count
DROP //
300 PUSHINT // _15=300
30 PUSHINT // _15=300 _16=30
}> // domain_char_count
DUP // domain_char_count domain_char_count
8 EQINT // domain_char_count _18
IFJMP:<{ // domain_char_count
DROP //
200 PUSHINT // _19=200
20 PUSHINT // _19=200 _20=20
}> // domain_char_count
DUP // domain_char_count domain_char_count
9 EQINT // domain_char_count _22
IFJMP:<{ // domain_char_count
DROP //
100 PUSHINT // _23=100
10 PUSHINT // _23=100 _24=10
}> // domain_char_count
10 EQINT // _26
IFJMP:<{ //
50 PUSHINT // _27=50
5 PUSHINT // _27=50 _28=5
}> //
10 PUSHINT // _29=10
1 PUSHINT // _29=10 _30=1
}>
get_min_price PROC:<{
// domain_bits_length now_time
SWAP // now_time domain_bits_length
3 RSHIFT# // now_time _5
get_min_price_config CALLDICT // now_time start_min_price end_min_price
SWAP
1000000000 PUSHINT // now_time end_min_price start_min_price _7=1000000000
MUL // now_time end_min_price start_min_price
SWAP
1000000000 PUSHINT // now_time start_min_price end_min_price _9=1000000000
MUL // now_time start_min_price end_min_price
s0 s2 XCHG
1659171600 PUSHINT // end_min_price start_min_price now_time _12=1659171600
SUB // end_min_price start_min_price seconds
2592000 PUSHINT // end_min_price start_min_price seconds _15=2592000
DIV // end_min_price start_min_price months
DUP // end_min_price start_min_price months months
21 GTINT // end_min_price start_min_price months _18
IFJMP:<{ // end_min_price start_min_price months
2DROP // end_min_price
}> // end_min_price start_min_price months
1 2 BLKDROP2 // start_min_price months
REPEAT:<{ // start_min_price
90 MULCONST // _20
100 PUSHINT // _20 _21=100
DIV // start_min_price
}>
}>
}END>c
boc>B "build/dns-utils.cell" B>file

205
build/dns-utils.fif

@ -0,0 +1,205 @@
"Asm.fif" include
// automatically generated from `contracts/dns-utils.fc` incl:`contracts/stdlib.fc`
PROGRAM{
DECLPROC zero_address
DECLPROC get_top_domain_bits
DECLPROC read_domain_from_comment
DECLPROC check_domain_string
DECLPROC get_min_price_config
DECLPROC get_min_price
zero_address PROC:<{
//
0 PUSHINT // _0=0
NEWC // _0=0 _1
2 STU // _3
ENDC // _4
CTOS // _5
}>
get_top_domain_bits PROC:<{
// domain
0 PUSHINT // domain i=0
UNTIL:<{
SWAP // i domain
8 LDU // i char domain
SWAP // i domain char
0 EQINT // i domain need_break
DUP // i domain need_break need_break
NOT // i domain need_break _11
IF:<{ // i domain need_break
s0 s2 XCHG // need_break domain i
8 ADDCONST // need_break domain i
s0 s2 XCHG // i domain need_break
}> // i domain need_break
s1 s2 XCHG // domain i need_break
}> // domain i
NIP // i
DUP // i i
0 EQINT // i _16
201 THROWIF
}>
read_domain_from_comment PROC:<{
// in_msg_body
NEWC // in_msg_body result
UNTIL:<{
OVER // in_msg_body result in_msg_body
SBITS // in_msg_body result _6
s1 s2 XCHG // result in_msg_body _6
LDSLICEX // result _5 in_msg_body
-ROT // in_msg_body result _5
STSLICER // in_msg_body result
OVER // in_msg_body result in_msg_body
SREFS // in_msg_body result refs_len
DUP // in_msg_body result refs_len refs_len
0 EQINT // in_msg_body result refs_len need_break
DUP // in_msg_body result refs_len need_break need_break
NOT // in_msg_body result refs_len need_break _13
IF:<{ // in_msg_body result refs_len need_break
SWAP // in_msg_body result need_break refs_len
1 EQINT // in_msg_body result need_break _16
202 THROWIFNOT
s0 s2 XCHG // need_break result in_msg_body
LDREF // need_break result _26 _25
DROP // need_break result _18
CTOS // need_break result in_msg_body
s0 s2 XCHG // in_msg_body result need_break
}>ELSE<{
NIP // in_msg_body result need_break
}>
}> // in_msg_body result
NIP // result
ENDC // _21
CTOS // _22
}>
check_domain_string PROC:<{
// domain
0 PUSHINT // domain i=0
OVER // domain i=0 domain
SBITS // domain i=0 len
UNTIL:<{
2DUP // domain i len i len
EQUAL // domain i len need_break
DUP // domain i len need_break need_break
NOT // domain i len need_break _8
IF:<{ // domain i len need_break
DROP // domain i len
s0 s2 XCHG // len i domain
8 LDU // len i char domain
OVER // len i char domain char
45 EQINT // len i char domain is_hyphen
s3 PUSH // len i char domain is_hyphen i
0 GTINT // len i char domain is_hyphen _18
AND // len i char domain _19
s4 PUSH // len i char domain _19 len
-8 ADDCONST // len i char domain _19 _21
s4 s(-1) PUXC // len i char domain _19 i _21
LESS // len i char domain _19 _22
AND // len i char domain _23
s2 PUSH // len i char domain _23 char
47 GTINT // len i char domain _23 _25
s3 PUSH // len i char domain _23 _25 char
58 LESSINT // len i char domain _23 _25 _27
AND // len i char domain _23 _28
OR // len i char domain _29
s2 PUSH // len i char domain _29 char
96 GTINT // len i char domain _29 _31
s0 s3 XCHG // len i _31 domain _29 char
123 LESSINT // len i _31 domain _29 _33
s1 s3 XCHG // len i _29 domain _31 _33
AND // len i _29 domain _34
s1 s2 XCHG // len i domain _29 _34
OR // len i domain valid_char
NOT // len i domain need_break
DUP // len i domain need_break need_break
NOT // len i domain need_break _37
IF:<{ // len i domain need_break
s0 s2 XCHG // len need_break domain i
8 ADDCONST // len need_break domain i
s0 s2 XCHG // len i domain need_break
}> // len i domain need_break
s1 s3 XCHG // domain i len need_break
}> // domain i len need_break
}> // domain i len
1 2 BLKDROP2 // i len
EQUAL // _40
}>
get_min_price_config PROC:<{
// domain_char_count
DUP // domain_char_count domain_char_count
4 EQINT // domain_char_count _2
IFJMP:<{ // domain_char_count
DROP //
1000 PUSHINT // _3=1000
100 PUSHINT // _3=1000 _4=100
}> // domain_char_count
DUP // domain_char_count domain_char_count
5 EQINT // domain_char_count _6
IFJMP:<{ // domain_char_count
DROP //
500 PUSHINT // _7=500
50 PUSHINT // _7=500 _8=50
}> // domain_char_count
DUP // domain_char_count domain_char_count
6 EQINT // domain_char_count _10
IFJMP:<{ // domain_char_count
DROP //
400 PUSHINT // _11=400
40 PUSHINT // _11=400 _12=40
}> // domain_char_count
DUP // domain_char_count domain_char_count
7 EQINT // domain_char_count _14
IFJMP:<{ // domain_char_count
DROP //
300 PUSHINT // _15=300
30 PUSHINT // _15=300 _16=30
}> // domain_char_count
DUP // domain_char_count domain_char_count
8 EQINT // domain_char_count _18
IFJMP:<{ // domain_char_count
DROP //
200 PUSHINT // _19=200
20 PUSHINT // _19=200 _20=20
}> // domain_char_count
DUP // domain_char_count domain_char_count
9 EQINT // domain_char_count _22
IFJMP:<{ // domain_char_count
DROP //
100 PUSHINT // _23=100
10 PUSHINT // _23=100 _24=10
}> // domain_char_count
10 EQINT // _26
IFJMP:<{ //
50 PUSHINT // _27=50
5 PUSHINT // _27=50 _28=5
}> //
10 PUSHINT // _29=10
1 PUSHINT // _29=10 _30=1
}>
get_min_price PROC:<{
// domain_bits_length now_time
SWAP // now_time domain_bits_length
3 RSHIFT# // now_time _5
get_min_price_config CALLDICT // now_time start_min_price end_min_price
SWAP
1000000000 PUSHINT // now_time end_min_price start_min_price _7=1000000000
MUL // now_time end_min_price start_min_price
SWAP
1000000000 PUSHINT // now_time start_min_price end_min_price _9=1000000000
MUL // now_time start_min_price end_min_price
s0 s2 XCHG
1659171600 PUSHINT // end_min_price start_min_price now_time _12=1659171600
SUB // end_min_price start_min_price seconds
2592000 PUSHINT // end_min_price start_min_price seconds _15=2592000
DIV // end_min_price start_min_price months
DUP // end_min_price start_min_price months months
21 GTINT // end_min_price start_min_price months _18
IFJMP:<{ // end_min_price start_min_price months
2DROP // end_min_price
}> // end_min_price start_min_price months
1 2 BLKDROP2 // start_min_price months
REPEAT:<{ // start_min_price
90 MULCONST // _20
100 PUSHINT // _20 _21=100
DIV // start_min_price
}>
}>
}END>c

1
build/main.compiled.json

@ -0,0 +1 @@
{"hex":"b5ee9c72c102370100062800000d00120017001c00210093009f00a400b100bd00c200c700cc00de00e600f000f501020108010d0112015b016001700175017a018e01a801ad01bd01d801dd01e201e701ec02220230023502480253029f02a402ce02d302d802f402fd037c03fe048104f2050b058605d006280114ff00f4a413f4bcf2c80b0102016213020201200a030201200704020120060500dfb461843ae92f152118001e5c08de01ebe11a1a60e038001e5c339e8086045ae140f800047ae938010a421611c2460644180012660f003c003060fe81e60f003c0d842412a03a60e6203bc43e006a245ae3061f2030401752791961e030402cf47da87b19e2d920322f122e1c425400300013b64a5e01e2050be11a1002014809080015b016fc03d7c21ffc0084a00013b3f3fc03d7c0cd100d20020120100b0202740f0c0201200e0d001fa74661e01e20acbe0c65e020e003e023000ba6b3e01ed9030010a874f00f10385f0802012012110015b6739da89a1a863ae17ff00007b56ba6300202cb1f140201201615008ddb836b692e4660be5fffc14678b2802678b0afa00667a0009659fe4f80bb810f808c10821bee20464658fe4b8bbc00c646582a802678b387d0109e5b589e665806664c0207d8040201201817001bf381064658089fa007a00658064c0201201c190201201b1a00233c04a0804ce73b50f600723332fff27b5520002f01b2330572ffd400f3c58073c5853304f304bd0032cff2600201201e1d001b3e401d3232c084b281f2fff27420003108323304b2fffe0a33c5b25c083232c044fd003d0032c03260020120292002012028210201202522020120242300673b5134350c343534fffe900835d270802384fe90351fc0753d0134cfcc04120411d788c40d380c1b5c1b5b5b48c4160415c411a00017321400f3c5807e80b2cff26002012027260021081ba50c1b5c0838343e903e8034cfcc2000113e910c1c2ebcb8536000936483001258c2040fa201938083001658c20407d200cb8083001a58c204064200a38083001e58c20404b2007b8083002258c204032200538083002650c20191eb83002a4e00c9d781e9c60201202b2a004fd64471010eba4896b8c2ce78b10eba51060001059cd80e000f97065016a1868014898f17318e4e840201202f2c0201202e2d00331c27c074c1c07000082ce500a98200b784b98c4830003cb43260000d1c3232c072742002f5420c70094840ff2f0def8276f1021c70091709401d31f59e203d0d3030171b0925f05e0fa40fa4031fa003171d721fa0031fa0030f00f26b3e302534ac70517b08e3410bd5f0dfa40307020f8256d8040708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00e020f00d8363001fef82301bc0ed33f246eb301111001b08e6a333453bea182103b9aca005210a15250bc993482103b9aca0014a1923003e220c2008e378210370fec516d72275134544643708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb001ba10a9130e25477645476546d520df0130592385be23102fe8210437dc40852d0ba925f0ee0821016c7d43552d0ba8e4410685f083233018308d718d3fff82801d4308201339ced43d8c827cf165003cf165230cbff5210ccc9f900fe005042f910f2e19d5340be313403f2e19e22f9005023f018e03d82101a039a5152c0ba9a175f076c42c705f2e191e082105fcc3d1452c0bae30236333200de363782101a0b9d515290ba8e1331375132c705f2e19a04d430415614f823f013e050795f0582102fcb26a214ba8e397082108b77173505c8cbff58cf161344408040708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00e05f04840ff2f0012c3b5370c705f2e191108b105a1049487615103402db3c3401f03502fa4021f00cfa40d20031fa0082103b9aca001ea121945314a0a1de22d70b01c300209205a19135e220c2fff2e192218e3e821005138d91c8500acf16500ecf1671244a145448b0708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00105a94102d385be2013500908e3529f00c8210d53276db103a450a6d71708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb0093393330e21056104510341023f823f01300ac5f0432333334355202c705f2e19502fa40d4306d70c8cb07f400c9f823821062e4f310a18208278d00a90420c20c9330800cde8208093a808208092c7058a8800ca904a1f82301a0f0024488f00e5e321034f823f0131160775b"}

1191
build/main.fif

File diff suppressed because it is too large Load Diff

1
build/nft-collection.compiled.json

@ -0,0 +1 @@
{"hex":"b5ee9c72c1022b010004b600000d00120017001c006d0072008a00a100a600c100c600da00e000e500ea010401090128012d013d01820187018c01a501aa0200024c02510256025b02d902df031e03600365036a039403b003b503be043b048804b60114ff00f4a413f4bcf2c80b010201620d0202012008030201200504009dba30c3020d74978a908c000f2e04620d70a07c00021d749c0085210b0935b786de0209501d3073101de21f0025122d71830f9018200ba93c8cb0f01820167a3ed43d8cf16c90191789170e212a001802012007060129b5347da89a1a9a9a9a7fff481a860206abe0bb67902a0029b60b7da89a1a9a9a9a7fff481a860be0affe0022500201200a090031ba7a3ed44d0d4d4d4d3fffa40d43010455f05f00f7001f01180201200c0b0023b4c7b91f0519e2c039e2c039e2d93a1f20300007b56ba6300202cb150e020148100f002fd38647c14678b2801e78b2801e78b6580e4e87c80acfc88402012012110039559f00f7021f011778018c8cb0558cf1670fa02cb6bccccc98040fb0080201201413001b3e401d3232c084b281f2fff274200085343500740075007435007400750c341c7232c1c933c58973c59633c5b272140133c58933c58073c5b24075007432140173c5940133c5b240f50c00b2333304b33332600201201b160201201817002df00e465fffc14678b64b81064658089fa007a00658064c0201481a1900a7200648f000e4cc20193788f00124cc200cb788f00164cc20067788f001a4cc20053788f001e4cc2003f788f002248c1eb780f082249d4cf79480ea1e9400e869c644a81eaa4120840ee6b2802a006a200caa41200093083001258c2040fa201938083001658c20407d200cb8083001a58c204064200a38083001e58c20404b2007b8083002258c204032200538083002650c20191eb83002a4e00c9d781e9c60020120221c020120211d020120201e01f50835d25c32086480ace39b88b000082ce3994134c1dc08b09008f056ec250c0069afe38d48b09808f05eec250c0069ae638988b08bc8f04eac250c0069812385c8b00b650c0c600fa740b017e4cc600fe53cb0410078b8b8b8b88129be083080251410b2c1669e14d02a4228514c33c07880a9819000c13780ba201f00086c31c9d000791c0875d272238b14c86e882ce3890c00f4c1c8700ec12982092ce5940972c1d411244cb888ecd4c8efac24fcb040f7941100f7b9b27400a844b5c60c20007f57021d7498e355cba20b38e2e3002d30721c02d23c200b024a6f85240b9b022c22f23c13ab0b122c26003c17b13b012b1b320b39402a60802de13dee66c12ba802012026230201202524004f3223880875d244b5c61673c58875d2883000082ce6c070007cb83280b50c3400a44c78b98c72742000331c27c074c1c07000082ce500a98200b784b98c4830003cb432600201202827000d1c3232c072742002f10831c0252103fcbc37807434c0c05c6c2497c0f80074c7fb513435353534fffe90350c0d49b00023b00c0d40fc00fc01948576cf05efbcb833097e40417e900c0930c02700fc01d518dcc1bc053cb833648cccf894903c0432140173c5b2721633c5b304f33244bc04f81b144860840dc3fb146ea497c138202a29009682102a0c8a2012ba8e3a01fa403021c705f2e19382102a0c8a2012706d71708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00e05f03840ff2f0005821d74920c218f2e0c8208103f0bbf2e0c92078a908c000f2e0ca02f005f2e0cbd0d307d3033002ab0202f0091e3c893b"}

11
build/nft-collection.deploy.ts

@ -1,15 +1,18 @@
import * as main from "../contracts/main";
import { Address, toNano, TupleSlice, WalletContract } from "ton";
// import { sendInternalMessageWithWallet } from "../test/helpers";
import { hex } from "../build/nft-item.compiled.json";
import {hex as item_code} from "../build/nft-item.compiled.json";
import { Builder, Cell, Slice } from "ton";
import BN from "bn.js";
// return the init Cell of the contract storage (according to load_data() contract method)
export function initData() {
let isTestnet = false;
return main.collectionData({
ownerAddress: Address.parseFriendly("kQBw4_jZTQVbOSDbUjAMibTHWbstrCqjOnzvUTCphGpTFDrK").address,
code: Cell.fromBoc(hex)[0],
ownerKey: 0 // 63181357919630091755807889549433422416741950993093777020964723182484811889834
ownerAddress: Address.parseFriendly("EQB_hLB81P0BuBqcitfwoLRd2QX4l4SY-w2fWob9xdWNQgSx").address,
code: Cell.fromBoc(item_code)[0],
zone: isTestnet ? "example.ton" : "nftcoffee.ton",
ownerKey: new BN(0) // 63181357919630091755807889549433422416741950993093777020964723182484811889834
});
}

845
build/nft-collection.fif

@ -0,0 +1,845 @@
"Asm.fif" include
// automatically generated from `contracts/nft-collection.fc` incl:`contracts/imports/dns-utils.fc` incl:`contracts/imports/stdlib.fc` incl:`contracts/imports/op-codes.fc` incl:`contracts/imports/params.fc`
PROGRAM{
DECLPROC zero_address
DECLPROC get_top_domain_bits
DECLPROC read_comment
DECLPROC read_domain_from_comment
DECLPROC check_domain_string
DECLPROC split_by_semicolon
DECLPROC decode_asciicode
DECLPROC get_min_price_config
DECLPROC price_function
DECLPROC get_min_price
DECLPROC force_chain
DECLPROC load_data
DECLPROC save_data
DECLPROC calcprice
DECLPROC calculate_nft_item_state_init
DECLPROC get_attachment
DECLPROC calculate_nft_item_address
DECLPROC send_msg
DECLPROC deploy_nft_item
DECLPROC verify_signature
DECLPROC recv_internal
102491 DECLMETHOD get_collection_data
92067 DECLMETHOD get_nft_address_by_index
68445 DECLMETHOD get_nft_content
108963 DECLMETHOD get_price
75325 DECLMETHOD signature_data
123660 DECLMETHOD dnsresolve
zero_address PROC:<{
//
0 PUSHINT // _0=0
NEWC // _0=0 _1
2 STU // _3
ENDC // _4
CTOS // _5
}>
get_top_domain_bits PROC:<{
// domain
0 PUSHINT // domain i=0
UNTIL:<{
SWAP // i domain
8 LDU // i char domain
SWAP // i domain char
0 EQINT // i domain need_break
DUP // i domain need_break need_break
NOT // i domain need_break _11
IF:<{ // i domain need_break
s0 s2 XCHG // need_break domain i
8 ADDCONST // need_break domain i
s0 s2 XCHG // i domain need_break
}> // i domain need_break
s1 s2 XCHG // domain i need_break
}> // domain i
NIP // i
DUP // i i
0 EQINT // i _16
201 THROWIF
}>
read_comment PROC:<{
// in_msg_body
NEWC // in_msg_body result
UNTIL:<{
OVER // in_msg_body result in_msg_body
SBITS // in_msg_body result _6
s1 s2 XCHG // result in_msg_body _6
LDSLICEX // result _5 in_msg_body
-ROT // in_msg_body result _5
STSLICER // in_msg_body result
OVER // in_msg_body result in_msg_body
SREFS // in_msg_body result refs_len
DUP // in_msg_body result refs_len refs_len
0 EQINT // in_msg_body result refs_len need_break
DUP // in_msg_body result refs_len need_break need_break
NOT // in_msg_body result refs_len need_break _13
IF:<{ // in_msg_body result refs_len need_break
SWAP // in_msg_body result need_break refs_len
1 EQINT // in_msg_body result need_break _16
202 THROWIFNOT
s0 s2 XCHG // need_break result in_msg_body
LDREF // need_break result _26 _25
DROP // need_break result _18
CTOS // need_break result in_msg_body
s0 s2 XCHG // in_msg_body result need_break
}>ELSE<{
NIP // in_msg_body result need_break
}>
}> // in_msg_body result
NIP // result
ENDC // _21
CTOS // _22
}>
read_domain_from_comment PROC:<{
// in_msg_body
read_comment CALLDICT // _1
}>
check_domain_string PROC:<{
// domain
0 PUSHINT // domain i=0
OVER // domain i=0 domain
SBITS // domain i=0 len
UNTIL:<{
2DUP // domain i len i len
EQUAL // domain i len need_break
DUP // domain i len need_break need_break
NOT // domain i len need_break _8
IF:<{ // domain i len need_break
DROP // domain i len
s0 s2 XCHG // len i domain
8 LDU // len i char domain
OVER // len i char domain char
45 EQINT // len i char domain is_hyphen
s3 PUSH // len i char domain is_hyphen i
0 GTINT // len i char domain is_hyphen _18
AND // len i char domain _19
s4 PUSH // len i char domain _19 len
-8 ADDCONST // len i char domain _19 _21
s4 s(-1) PUXC // len i char domain _19 i _21
LESS // len i char domain _19 _22
AND // len i char domain _23
s2 PUSH // len i char domain _23 char
47 GTINT // len i char domain _23 _25
s3 PUSH // len i char domain _23 _25 char
58 LESSINT // len i char domain _23 _25 _27
AND // len i char domain _23 _28
OR // len i char domain _29
s2 PUSH // len i char domain _29 char
96 GTINT // len i char domain _29 _31
s0 s3 XCHG // len i _31 domain _29 char
123 LESSINT // len i _31 domain _29 _33
s1 s3 XCHG // len i _29 domain _31 _33
AND // len i _29 domain _34
s1 s2 XCHG // len i domain _29 _34
OR // len i domain valid_char
NOT // len i domain need_break
DUP // len i domain need_break need_break
NOT // len i domain need_break _37
IF:<{ // len i domain need_break
s0 s2 XCHG // len need_break domain i
8 ADDCONST // len need_break domain i
s0 s2 XCHG // len i domain need_break
}> // len i domain need_break
s1 s3 XCHG // domain i len need_break
}> // domain i len need_break
}> // domain i len
1 2 BLKDROP2 // i len
EQUAL // _40
}>
split_by_semicolon PROC:<{
// str
0 PUSHINT // str i=0
OVER // str i=0 str
SBITS // str i=0 len
NEWC // str i=0 len result1
UNTIL:<{
s2 s1 PUSH2 // str i len result1 i len
EQUAL // str i len result1 need_break
DUP // str i len result1 need_break need_break
NOT // str i len result1 need_break _10
IF:<{ // str i len result1 need_break
DROP // str i len result1
s0 s3 XCHG // result1 i len str
8 LDU // result1 i len char str
OVER // result1 i len char str char
59 EQINT // result1 i len char str need_break
s0 s4 XCHG // result1 need_break len char str i
8 ADDCONST // result1 need_break len char str i
s4 PUSH // result1 need_break len char str i need_break
NOT // result1 need_break len char str i _19
IF:<{ // result1 need_break len char str i
s2 s5 XCHG2 // i need_break len str char result1
8 STU // i need_break len str result1
s4 s4 XCHG2 // result1 need_break len i str
}>ELSE<{
s2 POP // result1 need_break len i str
}>
s3 PUSH // result1 need_break len i str need_break
NOT // result1 need_break len i str _23
s2 s3 PUSH2 // result1 need_break len i str _23 i len
GEQ // result1 need_break len i str _23 _24
AND // result1 need_break len i str _25
IF:<{ // result1 need_break len i str
259 THROW
}> // result1 need_break len i str
s4 s4 XCHG2
s0 s3 XCHG // str i len result1 need_break
}> // str i len result1 need_break
}> // str i len result1
ENDC // str i len _28
CTOS // str i len _29
s0 s2 XCHG // str _29 len i
SUB // str _29 _31
s1 s2 XCHG // _29 str _31
LDSLICEX // _29 _36 _35
DROP // _29 _30
}>
decode_asciicode PROC:<{
// str
DUP // str str
SBITS // str len
0 PUSHINT // str len need_break=0
NEWC // str len need_break=0 result
OVER // str len need_break=0 result res_len=0
WHILE:<{
s0 s2 XCHG // str len res_len result need_break
NOT // str len res_len result _9
}>DO<{ // str len res_len result
s2 PUSH // str len res_len result len
0 EQINT // str len res_len result need_break
DUP // str len res_len result need_break need_break
NOT // str len res_len result need_break _12
IF:<{ // str len res_len result need_break
s0 s4 XCHG // need_break len res_len result str
8 LDU // need_break len res_len result char str
0 PUSHINT // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
64 GTINT // need_break len res_len result char str byte=0 _20
s3 PUSH // need_break len res_len result char str byte=0 _20 char
91 LESSINT // need_break len res_len result char str byte=0 _20 _22
AND // need_break len res_len result char str byte=0 _23
IF:<{ // need_break len res_len result char str byte=0
DROP // need_break len res_len result char str
SWAP // need_break len res_len result str char
-65 ADDCONST // need_break len res_len result str byte
}>ELSE<{ // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
96 GTINT // need_break len res_len result char str byte=0 _27
s3 PUSH // need_break len res_len result char str byte=0 _27 char
123 LESSINT // need_break len res_len result char str byte=0 _27 _29
AND // need_break len res_len result char str byte=0 _30
IF:<{ // need_break len res_len result char str byte=0
DROP // need_break len res_len result char str
SWAP // need_break len res_len result str char
-71 ADDCONST // need_break len res_len result str byte
}>ELSE<{ // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
47 GTINT // need_break len res_len result char str byte=0 _34
s3 PUSH // need_break len res_len result char str byte=0 _34 char
58 LESSINT // need_break len res_len result char str byte=0 _34 _36
AND // need_break len res_len result char str byte=0 _37
IF:<{ // need_break len res_len result char str byte=0
DROP // need_break len res_len result char str
SWAP // need_break len res_len result str char
4 ADDCONST // need_break len res_len result str byte
}>ELSE<{ // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
45 EQINT // need_break len res_len result char str byte=0 _41
IF:<{ // need_break len res_len result char str byte=0
DROP
NIP // need_break len res_len result str
62 PUSHINT // need_break len res_len result str byte=62
}>ELSE<{ // need_break len res_len result char str byte=0
s0 s2 XCHG // need_break len res_len result byte=0 str char
95 EQINT // need_break len res_len result byte=0 str _44
IF:<{ // need_break len res_len result byte=0 str
NIP // need_break len res_len result str
63 PUSHINT // need_break len res_len result str byte=63
}>ELSE<{ // need_break len res_len result byte=0 str
260 THROW
SWAP // need_break len res_len result str byte
}>
}>
}>
}>
}>
s0 s4 XCHG // need_break byte res_len result str len
-8 ADDCONST // need_break byte res_len result str len
DUP // need_break byte res_len result str len len
0 GTINT // need_break byte res_len result str len _51
IF:<{ // need_break byte res_len result str len
s4 s2 XCHG2 // need_break str res_len len byte result
6 STU // need_break str res_len len result
}>ELSE<{ // need_break byte res_len result str len
8 PUSHINT // need_break byte res_len result str len _56=8
s4 s0 PUSH2 // need_break byte res_len result str len _56=8 res_len _57=8
MOD // need_break byte res_len result str len _56=8 _58
SUB // need_break byte res_len result str len _59
s5 s3 s0 XCHG3 // need_break str res_len len byte result _59
STUX // need_break str res_len len result
}>
s0 s2 XCHG // need_break str result len res_len
6 ADDCONST // need_break str result len res_len
s0 s0 s3 XCHG3
s0 s4 XCHG // str len res_len result need_break
}> // str len res_len result need_break
s0 s2 XCHG // str len need_break result res_len
}> // str len res_len result
3 1 BLKDROP2 // result
ENDC // _63
CTOS // _64
}>
get_min_price_config PROC:<{
// domain_char_count
DUP // domain_char_count domain_char_count
4 EQINT // domain_char_count _2
IFJMP:<{ // domain_char_count
DROP //
1000 PUSHINT // _3=1000
100 PUSHINT // _3=1000 _4=100
}> // domain_char_count
DUP // domain_char_count domain_char_count
5 EQINT // domain_char_count _6
IFJMP:<{ // domain_char_count
DROP //
500 PUSHINT // _7=500
50 PUSHINT // _7=500 _8=50
}> // domain_char_count
DUP // domain_char_count domain_char_count
6 EQINT // domain_char_count _10
IFJMP:<{ // domain_char_count
DROP //
400 PUSHINT // _11=400
40 PUSHINT // _11=400 _12=40
}> // domain_char_count
DUP // domain_char_count domain_char_count
7 EQINT // domain_char_count _14
IFJMP:<{ // domain_char_count
DROP //
300 PUSHINT // _15=300
30 PUSHINT // _15=300 _16=30
}> // domain_char_count
DUP // domain_char_count domain_char_count
8 EQINT // domain_char_count _18
IFJMP:<{ // domain_char_count
DROP //
200 PUSHINT // _19=200
20 PUSHINT // _19=200 _20=20
}> // domain_char_count
DUP // domain_char_count domain_char_count
9 EQINT // domain_char_count _22
IFJMP:<{ // domain_char_count
DROP //
100 PUSHINT // _23=100
10 PUSHINT // _23=100 _24=10
}> // domain_char_count
10 EQINT // _26
IFJMP:<{ //
50 PUSHINT // _27=50
5 PUSHINT // _27=50 _28=5
}> //
10 PUSHINT // _29=10
1 PUSHINT // _29=10 _30=1
}>
price_function PROC:<{
// length multiplierx50 steepness
25 PUSHINT // length multiplierx50 steepness price=25
s3 PUSH // length multiplierx50 steepness price=25 length
3 EQINT // length multiplierx50 steepness price=25 _6
IF:<{ // length multiplierx50 steepness price=25
DROP // length multiplierx50 steepness
100 PUSHINT // length multiplierx50 steepness price=100
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
4 EQINT // length multiplierx50 steepness price _9
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
50 PUSHINT // length multiplierx50 steepness price=50
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
5 EQINT // length multiplierx50 steepness price _12
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
25 PUSHINT // length multiplierx50 steepness price=25
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
6 EQINT // length multiplierx50 steepness price _15
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
20 PUSHINT // length multiplierx50 steepness price=20
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
7 EQINT // length multiplierx50 steepness price _18
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
15 PUSHINT // length multiplierx50 steepness price=15
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
8 EQINT // length multiplierx50 steepness price _21
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
10 PUSHINT // length multiplierx50 steepness price=10
}> // length multiplierx50 steepness price
s0 s3 XCHG // price multiplierx50 steepness length
8 GTINT // price multiplierx50 steepness _24
IF:<{ // price multiplierx50 steepness
5 PUSHINT
s3 POP // price=5 multiplierx50 steepness
}> // price multiplierx50 steepness
s0 s2 PUXC // steepness multiplierx50 steepness price
MUL // steepness multiplierx50 _26
10 PUSHINT // steepness multiplierx50 _26 _27=10
s0 s3 XCHG2 // _26 multiplierx50 _27=10 steepness
SUB // _26 multiplierx50 _28
25 MULCONST // _26 multiplierx50 _30
s1 s2 XCHG // multiplierx50 _26 _30
ADD // multiplierx50 _31
10 PUSHINT // multiplierx50 _31 _32=10
DIV // multiplierx50 price
1000000000 PUSHINT // multiplierx50 price _34=1000000000
MUL // multiplierx50 _35
SWAP // _35 multiplierx50
MUL // _36
50 PUSHINT // _36 _37=50
DIV // _38
}>
get_min_price PROC:<{
// domain_bits_length now_time
SWAP // now_time domain_bits_length
3 RSHIFT# // now_time _5
get_min_price_config CALLDICT // now_time start_min_price end_min_price
SWAP
1000000000 PUSHINT // now_time end_min_price start_min_price _7=1000000000
MUL // now_time end_min_price start_min_price
SWAP
1000000000 PUSHINT // now_time start_min_price end_min_price _9=1000000000
MUL // now_time start_min_price end_min_price
s0 s2 XCHG
1659171600 PUSHINT // end_min_price start_min_price now_time _12=1659171600
SUB // end_min_price start_min_price seconds
2592000 PUSHINT // end_min_price start_min_price seconds _15=2592000
DIV // end_min_price start_min_price months
DUP // end_min_price start_min_price months months
21 GTINT // end_min_price start_min_price months _18
IFJMP:<{ // end_min_price start_min_price months
2DROP // end_min_price
}> // end_min_price start_min_price months
1 2 BLKDROP2 // start_min_price months
REPEAT:<{ // start_min_price
90 MULCONST // _20
100 PUSHINT // _20 _21=100
DIV // start_min_price
}>
}>
force_chain PROC:<{
// addr
REWRITESTDADDR // _8 _9
DROP // wc
0 PUSHINT // wc _5
EQUAL // _6
333 THROWIFNOT
}>
load_data PROCINLINE:<{
//
c4 PUSH // _1
CTOS // ds
LDREF // _3 ds
LDREF // _3 _5 ds
LDREF // _3 _5 _7 ds
256 LDU // _3 _5 _7 _9 ds
LDMSGADDR // _3 _5 _7 _9 _12 ds
LDREF // _3 _5 _7 _9 _12 _27 _26
DROP // _3 _5 _7 _9 _12 _14
}>
save_data PROCINLINE:<{
// content nft_item_code pricing owner_key owner_addr data_scheme
s0 s5 XCHG
NEWC // data_scheme nft_item_code pricing owner_key owner_addr content _6
STREF // data_scheme nft_item_code pricing owner_key owner_addr _7
s1 s4 XCHG // data_scheme owner_addr pricing owner_key nft_item_code _7
STREF // data_scheme owner_addr pricing owner_key _8
s1 s2 XCHG // data_scheme owner_addr owner_key pricing _8
STREF // data_scheme owner_addr owner_key _9
256 STU // data_scheme owner_addr _11
SWAP // data_scheme _11 owner_addr
STSLICER // data_scheme _12
STREF // _13
ENDC // _14
c4 POP
}>
calcprice PROCREF:<{
// domain pricing
OVER // domain pricing domain
SBITS // domain pricing len
DUP // domain pricing len len
24 GTINT // domain pricing len _8
200 THROWIFNOT
DUP
1008 PUSHINT // domain pricing len len _13
LEQ // domain pricing len _14
201 THROWIFNOT
DUP
8 PUSHINT // domain pricing len len _17=8
MOD // domain pricing len _18
0 EQINT // domain pricing len _20
202 THROWIFNOT
s0 s2 XCHG // len pricing domain
check_domain_string CALLDICT // len pricing _23
203 THROWIFNOT
CTOS // len pr
8 LDU // len multiplier pr
4 LDU // len multiplier _41 _40
DROP // len multiplier steepness
s0 s2 XCHG // steepness multiplier len
3 RSHIFT# // steepness multiplier _36
s0 s2 XCHG // _36 multiplier steepness
price_function CALLDICT // _37
}>
calculate_nft_item_state_init PROC:<{
// item_index nft_item_code
SWAP
NEWC // nft_item_code item_index _3
256 STU // nft_item_code _5
MYADDR // nft_item_code _5 _6
STSLICER // nft_item_code _7
ENDC // nft_item_code data
0 PUSHINT // nft_item_code data _9=0
DUP // nft_item_code data _9=0 _10=0
NEWC // nft_item_code data _9=0 _10=0 _11
2 STU // nft_item_code data _9=0 _13
s1 s3 XCHG // _9=0 data nft_item_code _13
STDICT // _9=0 data _14
STDICT // _9=0 _15
1 STU // _17
ENDC // _18
}>
get_attachment PROC:<{
// domain data_scheme
CTOS // domain cs
LDREF // domain _5 cs
SWAP // domain cs _5
CTOS // domain cs prefix
SWAP // domain prefix cs
LDREF // domain prefix _9 cs
SWAP // domain prefix cs _9
CTOS // domain prefix cs postfixes
LDREF // domain prefix cs _13 postfixes
SWAP // domain prefix cs postfixes _13
CTOS // domain prefix cs postfixes postfix
SWAP // domain prefix cs postfix postfixes
LDREF // domain prefix cs postfix _61 _60
DROP // domain prefix cs postfix _17
CTOS // domain prefix cs postfix image_postfix
1 PUSHINT // domain prefix cs postfix image_postfix _21=1
NEWC // domain prefix cs postfix image_postfix _21=1 _22
8 STU // domain prefix cs postfix image_postfix _24
s4 PUSH // domain prefix cs postfix image_postfix _24 prefix
STSLICER // domain prefix cs postfix image_postfix _25
s5 PUSH // domain prefix cs postfix image_postfix _25 domain
STSLICER // domain prefix cs postfix image_postfix _26
ROT // domain prefix cs image_postfix _26 postfix
STSLICER // domain prefix cs image_postfix _27
ENDC // domain prefix cs image_postfix uri_cell
NEWC // domain prefix cs image_postfix uri_cell _30
s0 s4 XCHG2 // domain uri_cell cs image_postfix _30 prefix
STSLICER // domain uri_cell cs image_postfix _31
s4 PUSH // domain uri_cell cs image_postfix _31 domain
STSLICER // domain uri_cell cs image_postfix _32
SWAP // domain uri_cell cs _32 image_postfix
STSLICER // domain uri_cell cs _33
ENDC // domain uri_cell cs image_uri_cell
SWAP // domain uri_cell image_uri_cell cs
LDREF // domain uri_cell image_uri_cell _36 cs
SWAP // domain uri_cell image_uri_cell cs _36
CTOS // domain uri_cell image_uri_cell cs zone
NEWC // domain uri_cell image_uri_cell cs zone _40
s0 s5 XCHG2 // zone uri_cell image_uri_cell cs _40 domain
STSLICER // zone uri_cell image_uri_cell cs _41
s0 s4 XCHG2 // cs uri_cell image_uri_cell _41 zone
STSLICER // cs uri_cell image_uri_cell _42
ENDC // cs uri_cell image_uri_cell name_cell
s0 s3 XCHG // name_cell uri_cell image_uri_cell cs
LDREF // name_cell uri_cell image_uri_cell _65 _64
DROP // name_cell uri_cell image_uri_cell desc_cell
s0 s2 XCHG
NEWC // name_cell desc_cell image_uri_cell uri_cell _48
STREF // name_cell desc_cell image_uri_cell _49
STREF // name_cell desc_cell _50
s1 s2 XCHG // desc_cell name_cell _50
STREF // desc_cell _51
STREF // _52
ENDC // full_cell
}>
calculate_nft_item_address PROC:<{
// wc state_init
HASHCU // wc _2
4 PUSHINT // wc _2 _3=4
NEWC // wc _2 _3=4 _4
3 STU // wc _2 _6
s1 s2 XCHG // _2 wc _6
8 STI // _2 _8
256 STU // _10
ENDC // _11
CTOS // _12
}>
send_msg PROCINLINE:<{
// to_address amount op query_id payload send_mode
0 PUSHINT // to_address amount op query_id payload send_mode _7=0
16 PUSHINT // to_address amount op query_id payload send_mode _7=0 _8=16
NEWC // to_address amount op query_id payload send_mode _7=0 _8=16 _9
6 STU // to_address amount op query_id payload send_mode _7=0 _11
s0 s7 XCHG2 // _7=0 amount op query_id payload send_mode _11 to_address
STSLICER // _7=0 amount op query_id payload send_mode _12
s0 s5 XCHG2 // _7=0 send_mode op query_id payload _12 amount
STVARUINT16 // _7=0 send_mode op query_id payload _13
s1 s5 XCHG // payload send_mode op query_id _7=0 _13
107 STU // payload send_mode op query_id _27
s1 s2 XCHG // payload send_mode query_id op _27
32 STU // payload send_mode query_id _29
64 STU // payload send_mode msg
s2 PUSH // payload send_mode msg payload
ISNULL // payload send_mode msg _32
NOT // payload send_mode msg _33
IF:<{ // payload send_mode msg
ROT // send_mode msg payload
STBR // send_mode msg
SWAP // msg send_mode
}>ELSE<{
s2 POP // msg send_mode
}>
SWAP // send_mode msg
ENDC // send_mode _35
SWAP // _35 send_mode
SENDRAWMSG
}>
deploy_nft_item PROC:<{
// item_index nft_item_code nft_payload
-ROT // nft_payload item_index nft_item_code
calculate_nft_item_state_init CALLDICT // nft_payload state_init
0 PUSHINT // nft_payload state_init _6
OVER // nft_payload state_init _6 state_init
calculate_nft_item_address CALLDICT // nft_payload state_init nft_address
7 PUSHINT // nft_payload state_init nft_address _13
24 PUSHINT // nft_payload state_init nft_address _13 _14=24
NEWC // nft_payload state_init nft_address _13 _14=24 _15
6 STU // nft_payload state_init nft_address _13 _17
ROT // nft_payload state_init _13 _17 nft_address
STSLICER // nft_payload state_init _13 _18
0 PUSHINT // nft_payload state_init _13 _18 _19=0
STVARUINT16 // nft_payload state_init _13 _20
108 STU // nft_payload state_init _36
STREF // nft_payload _37
STREF // msg
ENDC // _39
64 PUSHINT // _39 _40=64
SENDRAWMSG
}>
verify_signature PROC:<{
// signature sender_address domain owner_key
0 PUSHINT // signature sender_address domain owner_key _5=0
NEWC // signature sender_address domain owner_key _5=0 _6
MYADDR // signature sender_address domain owner_key _5=0 _6 _7
STSLICER // signature sender_address domain owner_key _5=0 _8
s0 s3 XCHG2 // signature sender_address _5=0 owner_key _8 domain
STSLICER // signature sender_address _5=0 owner_key _9
s0 s3 XCHG2 // signature owner_key _5=0 _9 sender_address
STSLICER // signature owner_key _5=0 _10
2 STU // signature owner_key _12
ENDC // signature owner_key option_data
CTOS // signature owner_key _14
HASHSU // signature owner_key _15
-ROT // _15 signature owner_key
CHKSIGNU // _16
}>
recv_internal PROC:<{
// msg_value in_msg_full in_msg_body
DUP // msg_value in_msg_full in_msg_body in_msg_body
SEMPTY // msg_value in_msg_full in_msg_body _3
IF:<{ // msg_value in_msg_full in_msg_body
16 PUSHPOW2DEC // msg_value in_msg_full in_msg_body _4=65535
THROWANY
}> // msg_value in_msg_full in_msg_body
SWAP // msg_value in_msg_body in_msg_full
CTOS // msg_value in_msg_body cs
4 LDU // msg_value in_msg_body flags cs
SWAP
1 PUSHINT // msg_value in_msg_body cs flags _12=1
AND // msg_value in_msg_body cs _13
IFJMP:<{ // msg_value in_msg_body cs
3 BLKDROP //
}> // msg_value in_msg_body cs
SWAP // msg_value cs in_msg_body
32 LDU // msg_value cs op in_msg_body
load_data INLINECALLDICT // msg_value cs op in_msg_body _85 _86 _87 _88 _89 _90
s5 POP // msg_value cs op in_msg_body data_scheme nft_item_code pricing key addr
s6 PUSH // msg_value cs op in_msg_body data_scheme nft_item_code pricing key addr op
0 EQINT // msg_value cs op in_msg_body data_scheme nft_item_code pricing key addr _26
IFJMP:<{ // msg_value cs op in_msg_body data_scheme nft_item_code pricing key addr
DROP
s5 POP // msg_value cs key in_msg_body data_scheme nft_item_code pricing
s0 s3 XCHG // msg_value cs key pricing data_scheme nft_item_code in_msg_body
read_comment CALLDICT // msg_value cs key pricing data_scheme nft_item_code body
split_by_semicolon CALLDICT // msg_value cs key pricing data_scheme nft_item_code domain signature_encoded
s1 s4 PUXC // msg_value cs key signature_encoded data_scheme nft_item_code domain domain pricing
calcprice INLINECALLDICT // msg_value cs key signature_encoded data_scheme nft_item_code domain price
s1 s7 XCHG // domain cs key signature_encoded data_scheme nft_item_code msg_value price
GEQ // domain cs key signature_encoded data_scheme nft_item_code _39
204 THROWIFNOT
s5 PUSH // domain cs key signature_encoded data_scheme nft_item_code domain
HASHSU // domain cs key signature_encoded data_scheme nft_item_code item_index
s0 s5 XCHG // domain item_index key signature_encoded data_scheme nft_item_code cs
LDMSGADDR // domain item_index key signature_encoded data_scheme nft_item_code _94 _93
DROP // domain item_index key signature_encoded data_scheme nft_item_code sender_address
s4 PUSH // domain item_index key signature_encoded data_scheme nft_item_code sender_address key
0 NEQINT // domain item_index key signature_encoded data_scheme nft_item_code sender_address _47
IF:<{ // domain item_index key signature_encoded data_scheme nft_item_code sender_address
s0 s3 XCHG // domain item_index key sender_address data_scheme nft_item_code signature_encoded
decode_asciicode CALLDICT // domain item_index key sender_address data_scheme nft_item_code signature
s3 s6 s1 PU2XC
s0 s6 XCHG // domain item_index nft_item_code sender_address data_scheme signature sender_address domain key
verify_signature CALLDICT // domain item_index nft_item_code sender_address data_scheme _51
205 THROWIFNOT
}>ELSE<{
s3 POP
s3 POP // domain item_index nft_item_code sender_address data_scheme
}>
s4 s(-1) PUXC // domain item_index nft_item_code sender_address domain data_scheme
get_attachment CALLDICT // domain item_index nft_item_code sender_address _54
NEWC // domain item_index nft_item_code sender_address _54 _55
s0 s5 XCHG2 // _54 item_index nft_item_code sender_address _55 domain
STSLICER // _54 item_index nft_item_code sender_address _56
ENDC // _54 item_index nft_item_code sender_address _57
NEWC
ROT // _54 item_index nft_item_code _57 _58 sender_address
STSLICER // _54 item_index nft_item_code _57 _59
STREF // _54 item_index nft_item_code _60
s1 s3 XCHG // nft_item_code item_index _54 _60
STREF // nft_item_code item_index _61
ENDC // nft_item_code item_index nft_content
s1 s2 XCHG // item_index nft_item_code nft_content
deploy_nft_item CALLDICT
}> // msg_value cs op in_msg_body data_scheme nft_item_code pricing key addr
5 1 BLKDROP2 // msg_value cs op addr
OVER
923790417 PUSHINT // msg_value cs op addr op _64=923790417
EQUAL // msg_value cs op addr _65
IFJMP:<{ // msg_value cs op addr
4 BLKDROP //
}> // msg_value cs op addr
0x2a0c8a20 PUSHINT // msg_value cs op addr _66
s1 s2 XCHG // msg_value cs addr op _66
EQUAL // msg_value cs addr _67
IFJMP:<{ // msg_value cs addr
SWAP // msg_value addr cs
LDMSGADDR // msg_value addr _96 _95
DROP // msg_value addr sender_address
OVER // msg_value addr sender_address addr
SDEQ // msg_value addr _72
403 THROWIFNOT
0x2a0c8a20 PUSHINT // msg_value addr _74
s1 s2 XCHG
0 PUSHINT
PUSHNULL
1 PUSHINT // addr msg_value _74 _75=0 _76 _77=1
send_msg INLINECALLDICT
}> // msg_value cs addr
3 BLKDROP //
16 PUSHPOW2DEC // _79=65535
THROWANY
}>
get_collection_data PROC:<{
//
load_data INLINECALLDICT // _9 _10 _11 _12 _13 _14
5 BLKDROP // content
-1 PUSHINT // content _7=-1
zero_address CALLDICT // content _7=-1 _8
s1 s2 XCHG // _7=-1 content _8
}>
get_nft_address_by_index PROC:<{
// index
load_data INLINECALLDICT // index _12 _13 _14 _15 _16 _17
s4 s5 XCHG
5 BLKDROP // index nft_item_code
calculate_nft_item_state_init CALLDICT // state_init
0 PUSHINT // state_init _10
SWAP // _10 state_init
calculate_nft_item_address CALLDICT // _11
}>
get_nft_content PROC:<{
// index individual_nft_content
NIP // individual_nft_content
}>
get_price PROC:<{
// domain
load_data INLINECALLDICT // domain _9 _10 _11 _12 _13 _14
s3 s5 XCHG
5 BLKDROP // domain pricing
calcprice INLINECALLDICT // _8
}>
signature_data PROC:<{
// sender_address domain
NEWC // sender_address domain _3
MYADDR // sender_address domain _3 _4
STSLICER // sender_address domain _5
SWAP // sender_address _5 domain
STSLICER // sender_address _6
SWAP // _6 sender_address
STSLICER // _7
ENDC // option_data
CTOS // _9
HASHSU // _10
}>
dnsresolve PROC:<{
// subdomain category
DROP // subdomain
DUP // subdomain subdomain
SBITS // subdomain _3
8 PUSHINT // subdomain _3 _4=8
MOD // subdomain _5
0 EQINT // subdomain _7
70 THROWIFNOT
DUP // subdomain subdomain
8 PLDI // subdomain _11
0 EQINT // subdomain starts_with_zero_byte
OVER // subdomain starts_with_zero_byte subdomain
SBITS // subdomain starts_with_zero_byte _14
8 EQINT // subdomain starts_with_zero_byte _16
s1 s(-1) PUXC // subdomain starts_with_zero_byte starts_with_zero_byte _16
AND // subdomain starts_with_zero_byte _17
IFJMP:<{ // subdomain starts_with_zero_byte
2DROP //
8 PUSHINT // _18=8
PUSHNULL // _18=8 _19
}> // subdomain starts_with_zero_byte
DUP // subdomain starts_with_zero_byte starts_with_zero_byte
IF:<{ // subdomain starts_with_zero_byte
SWAP // starts_with_zero_byte subdomain
8 LDU // starts_with_zero_byte _43 _42
NIP // starts_with_zero_byte subdomain
SWAP // subdomain starts_with_zero_byte
}> // subdomain starts_with_zero_byte
OVER // subdomain starts_with_zero_byte subdomain
get_top_domain_bits CALLDICT // subdomain starts_with_zero_byte top_subdomain_bits
s2 s2 XCPU // top_subdomain_bits starts_with_zero_byte subdomain top_subdomain_bits
LDSLICEX // top_subdomain_bits starts_with_zero_byte _45 _44
DROP // top_subdomain_bits starts_with_zero_byte top_subdomain
HASHSU // top_subdomain_bits starts_with_zero_byte item_index
47763 PUSHINT // top_subdomain_bits starts_with_zero_byte item_index _31=47763
NEWC // top_subdomain_bits starts_with_zero_byte item_index _31=47763 _32
16 STU // top_subdomain_bits starts_with_zero_byte item_index _34
SWAP // top_subdomain_bits starts_with_zero_byte _34 item_index
get_nft_address_by_index CALLDICT // top_subdomain_bits starts_with_zero_byte _34 _35
STSLICER // top_subdomain_bits starts_with_zero_byte _36
ENDC // top_subdomain_bits starts_with_zero_byte result
SWAP // top_subdomain_bits result starts_with_zero_byte
IF:<{ // top_subdomain_bits result
8 PUSHINT // top_subdomain_bits result _38=8
}>ELSE<{ // top_subdomain_bits result
0 PUSHINT // top_subdomain_bits result _38=0
}>
s1 s2 XCHG // result top_subdomain_bits _38
ADD // result _41
SWAP // _41 result
}>
}END>c

1
build/nft-item.compiled.json

@ -0,0 +1 @@
{"hex":"b5ee9c72c1021f0100053000000d00120017001c002100850090009b00a100a900b300b800bd00c200d9010301080113015f0164018e020d027802bc0339037f03fa043f044c04b605300114ff00f4a413f4bcf2c80b010201620b0202012008030201200704020120060500c3b461843ae9240f152118001e5c08de018206ebe0fa1a60e038001e5c339e8086007ae140f8001e5c33b84111c466105e033e04883dcb11fb64ddc4964ad1ba06b879240dc23572f37cc5caaab143a2fffbc4180012660f003c003060fe81e60f00300011b64a5e0182ebe0fa100011b8fcff00c10235f03802037b200a09000ca959f00c6c710010a874f00c10475f070202cc130c020120100d0201480f0e002901b232ffd40173c59400f3c5b3333332cff27b5520004f3b513434fffe900835d27080279fc07e9035353534cfcc0415c415b80c1c1b5b5b5b490415c415a0020120121100115fa443070baf2e14d80093420c00496308103e88064e020c00596308101f48032e020c00696308101908028e020c007963081012c801ee020c00896308100c88014e020c009943080647ae0c00a93803275e07a7180201481514004f5c88e2021d74912d71859cf1621d74a20c00020b39b01c001f2e0ca02d430d0029131e2e631c9d0803f34f8276f1002d0d3030171b0925f04e0fa40fa4031fa003171d721fa0031fa0030f00c3026b3e3023b5337c70516b08e3410795f09fa40307020f8256d8040708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00e027c70091709507d31f5088e220c000e30208d33f81d1c1604ca82105fcc3d1452a0ba8e95395372c705f2e191109a104910384760441302db3ce082101a0b9d5152a0ba8e16365b3435355121c705f2e19a01d4d4305504f823f00de02982104eb1f0f9bae3023028821044beae41bae302355b33353582102fcb26a213ba1a19181700848e397082108b77173504c8cbff5003cf165e218040708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00e05f04840ff2f001f4388050f833d0f4043052408307f40e6fa1f2e19fd30721c00022c001b1f2e1a021c0008e9324109b10680710461035514a104c030ddb3c129630103a395f07e201c0018e32708210370fec51586d8100a0708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00915be21a0088313637375146c705f2e19b02d3ff20d74ac20006d0d30701c000f2e19cf404300698d43040158307f417983050048307f45b30e270c8cb07f400c94014503305f823f00d01f03401fa4021f00bfa40d20031fa0082101dcd65001da121945314a0a1de22d70b01c300209205a19135e220c2fff2e192218e3e821005138d91c8500bcf16500dcf1671244b145447c0708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00106994102c395be2011b00868e3528f00b8210d53276db103946066d71708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00941028355be25504f823f00d001630353535355504f823f00d01ce5f0432355203c705f2e19502fa40d4d430d0d4d4d4d4306d1382f06105d6cc76af400325e94d588ce511be5bfdbb73b437dc51eca43917d7a43e3d018307f41782f082a3537ff0dbce7eec35d69edc3a189ee6f17d82f353a553f9aa96cb0be3ce89018307f4171e00f082f0c9046f7a37ad0ea7cee73355984fa5428982f8b37c8f7bcec91f7ac71a7cd104018307f41770c8cb07f400c9241057045023f823f00d12a182101dcd6500a120c2008e2f8210d53276db706d71708010c8cb055007cf165005fa0215cb6a12cb1fcb3f226eb39458cf17019132e201c901fb00915be2185ba0cd"}

944
build/nft-item.fif

@ -0,0 +1,944 @@
"Asm.fif" include
// automatically generated from `contracts/nft-item.fc` incl:`contracts/imports/dns-utils.fc` incl:`contracts/imports/stdlib.fc` incl:`contracts/imports/op-codes.fc` incl:`contracts/imports/params.fc`
PROGRAM{
DECLPROC zero_address
DECLPROC get_top_domain_bits
DECLPROC read_comment
DECLPROC read_domain_from_comment
DECLPROC check_domain_string
DECLPROC split_by_semicolon
DECLPROC decode_asciicode
DECLPROC get_min_price_config
DECLPROC price_function
DECLPROC get_min_price
DECLPROC force_chain
DECLPROC load_data
DECLPROC store_data
DECLPROC send_msg
DECLPROC transfer_ownership
DECLPROC recv_internal
102351 DECLMETHOD get_nft_data
90228 DECLMETHOD get_editor
119378 DECLMETHOD get_domain
91481 DECLMETHOD get_last_fill_up_time
123660 DECLMETHOD dnsresolve
zero_address PROC:<{
//
0 PUSHINT // _0=0
NEWC // _0=0 _1
2 STU // _3
ENDC // _4
CTOS // _5
}>
get_top_domain_bits PROC:<{
// domain
0 PUSHINT // domain i=0
UNTIL:<{
SWAP // i domain
8 LDU // i char domain
SWAP // i domain char
0 EQINT // i domain need_break
DUP // i domain need_break need_break
NOT // i domain need_break _11
IF:<{ // i domain need_break
s0 s2 XCHG // need_break domain i
8 ADDCONST // need_break domain i
s0 s2 XCHG // i domain need_break
}> // i domain need_break
s1 s2 XCHG // domain i need_break
}> // domain i
NIP // i
DUP // i i
0 EQINT // i _16
201 THROWIF
}>
read_comment PROC:<{
// in_msg_body
NEWC // in_msg_body result
UNTIL:<{
OVER // in_msg_body result in_msg_body
SBITS // in_msg_body result _6
s1 s2 XCHG // result in_msg_body _6
LDSLICEX // result _5 in_msg_body
-ROT // in_msg_body result _5
STSLICER // in_msg_body result
OVER // in_msg_body result in_msg_body
SREFS // in_msg_body result refs_len
DUP // in_msg_body result refs_len refs_len
0 EQINT // in_msg_body result refs_len need_break
DUP // in_msg_body result refs_len need_break need_break
NOT // in_msg_body result refs_len need_break _13
IF:<{ // in_msg_body result refs_len need_break
SWAP // in_msg_body result need_break refs_len
1 EQINT // in_msg_body result need_break _16
202 THROWIFNOT
s0 s2 XCHG // need_break result in_msg_body
LDREF // need_break result _26 _25
DROP // need_break result _18
CTOS // need_break result in_msg_body
s0 s2 XCHG // in_msg_body result need_break
}>ELSE<{
NIP // in_msg_body result need_break
}>
}> // in_msg_body result
NIP // result
ENDC // _21
CTOS // _22
}>
read_domain_from_comment PROC:<{
// in_msg_body
read_comment CALLDICT // _1
}>
check_domain_string PROC:<{
// domain
0 PUSHINT // domain i=0
OVER // domain i=0 domain
SBITS // domain i=0 len
UNTIL:<{
2DUP // domain i len i len
EQUAL // domain i len need_break
DUP // domain i len need_break need_break
NOT // domain i len need_break _8
IF:<{ // domain i len need_break
DROP // domain i len
s0 s2 XCHG // len i domain
8 LDU // len i char domain
OVER // len i char domain char
45 EQINT // len i char domain is_hyphen
s3 PUSH // len i char domain is_hyphen i
0 GTINT // len i char domain is_hyphen _18
AND // len i char domain _19
s4 PUSH // len i char domain _19 len
-8 ADDCONST // len i char domain _19 _21
s4 s(-1) PUXC // len i char domain _19 i _21
LESS // len i char domain _19 _22
AND // len i char domain _23
s2 PUSH // len i char domain _23 char
47 GTINT // len i char domain _23 _25
s3 PUSH // len i char domain _23 _25 char
58 LESSINT // len i char domain _23 _25 _27
AND // len i char domain _23 _28
OR // len i char domain _29
s2 PUSH // len i char domain _29 char
96 GTINT // len i char domain _29 _31
s0 s3 XCHG // len i _31 domain _29 char
123 LESSINT // len i _31 domain _29 _33
s1 s3 XCHG // len i _29 domain _31 _33
AND // len i _29 domain _34
s1 s2 XCHG // len i domain _29 _34
OR // len i domain valid_char
NOT // len i domain need_break
DUP // len i domain need_break need_break
NOT // len i domain need_break _37
IF:<{ // len i domain need_break
s0 s2 XCHG // len need_break domain i
8 ADDCONST // len need_break domain i
s0 s2 XCHG // len i domain need_break
}> // len i domain need_break
s1 s3 XCHG // domain i len need_break
}> // domain i len need_break
}> // domain i len
1 2 BLKDROP2 // i len
EQUAL // _40
}>
split_by_semicolon PROC:<{
// str
0 PUSHINT // str i=0
OVER // str i=0 str
SBITS // str i=0 len
NEWC // str i=0 len result1
UNTIL:<{
s2 s1 PUSH2 // str i len result1 i len
EQUAL // str i len result1 need_break
DUP // str i len result1 need_break need_break
NOT // str i len result1 need_break _10
IF:<{ // str i len result1 need_break
DROP // str i len result1
s0 s3 XCHG // result1 i len str
8 LDU // result1 i len char str
OVER // result1 i len char str char
59 EQINT // result1 i len char str need_break
s0 s4 XCHG // result1 need_break len char str i
8 ADDCONST // result1 need_break len char str i
s4 PUSH // result1 need_break len char str i need_break
NOT // result1 need_break len char str i _19
IF:<{ // result1 need_break len char str i
s2 s5 XCHG2 // i need_break len str char result1
8 STU // i need_break len str result1
s4 s4 XCHG2 // result1 need_break len i str
}>ELSE<{
s2 POP // result1 need_break len i str
}>
s3 PUSH // result1 need_break len i str need_break
NOT // result1 need_break len i str _23
s2 s3 PUSH2 // result1 need_break len i str _23 i len
GEQ // result1 need_break len i str _23 _24
AND // result1 need_break len i str _25
IF:<{ // result1 need_break len i str
259 THROW
}> // result1 need_break len i str
s4 s4 XCHG2
s0 s3 XCHG // str i len result1 need_break
}> // str i len result1 need_break
}> // str i len result1
ENDC // str i len _28
CTOS // str i len _29
s0 s2 XCHG // str _29 len i
SUB // str _29 _31
s1 s2 XCHG // _29 str _31
LDSLICEX // _29 _36 _35
DROP // _29 _30
}>
decode_asciicode PROC:<{
// str
DUP // str str
SBITS // str len
0 PUSHINT // str len need_break=0
NEWC // str len need_break=0 result
OVER // str len need_break=0 result res_len=0
WHILE:<{
s0 s2 XCHG // str len res_len result need_break
NOT // str len res_len result _9
}>DO<{ // str len res_len result
s2 PUSH // str len res_len result len
0 EQINT // str len res_len result need_break
DUP // str len res_len result need_break need_break
NOT // str len res_len result need_break _12
IF:<{ // str len res_len result need_break
s0 s4 XCHG // need_break len res_len result str
8 LDU // need_break len res_len result char str
0 PUSHINT // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
64 GTINT // need_break len res_len result char str byte=0 _20
s3 PUSH // need_break len res_len result char str byte=0 _20 char
91 LESSINT // need_break len res_len result char str byte=0 _20 _22
AND // need_break len res_len result char str byte=0 _23
IF:<{ // need_break len res_len result char str byte=0
DROP // need_break len res_len result char str
SWAP // need_break len res_len result str char
-65 ADDCONST // need_break len res_len result str byte
}>ELSE<{ // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
96 GTINT // need_break len res_len result char str byte=0 _27
s3 PUSH // need_break len res_len result char str byte=0 _27 char
123 LESSINT // need_break len res_len result char str byte=0 _27 _29
AND // need_break len res_len result char str byte=0 _30
IF:<{ // need_break len res_len result char str byte=0
DROP // need_break len res_len result char str
SWAP // need_break len res_len result str char
-71 ADDCONST // need_break len res_len result str byte
}>ELSE<{ // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
47 GTINT // need_break len res_len result char str byte=0 _34
s3 PUSH // need_break len res_len result char str byte=0 _34 char
58 LESSINT // need_break len res_len result char str byte=0 _34 _36
AND // need_break len res_len result char str byte=0 _37
IF:<{ // need_break len res_len result char str byte=0
DROP // need_break len res_len result char str
SWAP // need_break len res_len result str char
4 ADDCONST // need_break len res_len result str byte
}>ELSE<{ // need_break len res_len result char str byte=0
s2 PUSH // need_break len res_len result char str byte=0 char
45 EQINT // need_break len res_len result char str byte=0 _41
IF:<{ // need_break len res_len result char str byte=0
DROP
NIP // need_break len res_len result str
62 PUSHINT // need_break len res_len result str byte=62
}>ELSE<{ // need_break len res_len result char str byte=0
s0 s2 XCHG // need_break len res_len result byte=0 str char
95 EQINT // need_break len res_len result byte=0 str _44
IF:<{ // need_break len res_len result byte=0 str
NIP // need_break len res_len result str
63 PUSHINT // need_break len res_len result str byte=63
}>ELSE<{ // need_break len res_len result byte=0 str
260 THROW
SWAP // need_break len res_len result str byte
}>
}>
}>
}>
}>
s0 s4 XCHG // need_break byte res_len result str len
-8 ADDCONST // need_break byte res_len result str len
DUP // need_break byte res_len result str len len
0 GTINT // need_break byte res_len result str len _51
IF:<{ // need_break byte res_len result str len
s4 s2 XCHG2 // need_break str res_len len byte result
6 STU // need_break str res_len len result
}>ELSE<{ // need_break byte res_len result str len
8 PUSHINT // need_break byte res_len result str len _56=8
s4 s0 PUSH2 // need_break byte res_len result str len _56=8 res_len _57=8
MOD // need_break byte res_len result str len _56=8 _58
SUB // need_break byte res_len result str len _59
s5 s3 s0 XCHG3 // need_break str res_len len byte result _59
STUX // need_break str res_len len result
}>
s0 s2 XCHG // need_break str result len res_len
6 ADDCONST // need_break str result len res_len
s0 s0 s3 XCHG3
s0 s4 XCHG // str len res_len result need_break
}> // str len res_len result need_break
s0 s2 XCHG // str len need_break result res_len
}> // str len res_len result
3 1 BLKDROP2 // result
ENDC // _63
CTOS // _64
}>
get_min_price_config PROC:<{
// domain_char_count
DUP // domain_char_count domain_char_count
4 EQINT // domain_char_count _2
IFJMP:<{ // domain_char_count
DROP //
1000 PUSHINT // _3=1000
100 PUSHINT // _3=1000 _4=100
}> // domain_char_count
DUP // domain_char_count domain_char_count
5 EQINT // domain_char_count _6
IFJMP:<{ // domain_char_count
DROP //
500 PUSHINT // _7=500
50 PUSHINT // _7=500 _8=50
}> // domain_char_count
DUP // domain_char_count domain_char_count
6 EQINT // domain_char_count _10
IFJMP:<{ // domain_char_count
DROP //
400 PUSHINT // _11=400
40 PUSHINT // _11=400 _12=40
}> // domain_char_count
DUP // domain_char_count domain_char_count
7 EQINT // domain_char_count _14
IFJMP:<{ // domain_char_count
DROP //
300 PUSHINT // _15=300
30 PUSHINT // _15=300 _16=30
}> // domain_char_count
DUP // domain_char_count domain_char_count
8 EQINT // domain_char_count _18
IFJMP:<{ // domain_char_count
DROP //
200 PUSHINT // _19=200
20 PUSHINT // _19=200 _20=20
}> // domain_char_count
DUP // domain_char_count domain_char_count
9 EQINT // domain_char_count _22
IFJMP:<{ // domain_char_count
DROP //
100 PUSHINT // _23=100
10 PUSHINT // _23=100 _24=10
}> // domain_char_count
10 EQINT // _26
IFJMP:<{ //
50 PUSHINT // _27=50
5 PUSHINT // _27=50 _28=5
}> //
10 PUSHINT // _29=10
1 PUSHINT // _29=10 _30=1
}>
price_function PROC:<{
// length multiplierx50 steepness
25 PUSHINT // length multiplierx50 steepness price=25
s3 PUSH // length multiplierx50 steepness price=25 length
3 EQINT // length multiplierx50 steepness price=25 _6
IF:<{ // length multiplierx50 steepness price=25
DROP // length multiplierx50 steepness
100 PUSHINT // length multiplierx50 steepness price=100
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
4 EQINT // length multiplierx50 steepness price _9
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
50 PUSHINT // length multiplierx50 steepness price=50
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
5 EQINT // length multiplierx50 steepness price _12
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
25 PUSHINT // length multiplierx50 steepness price=25
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
6 EQINT // length multiplierx50 steepness price _15
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
20 PUSHINT // length multiplierx50 steepness price=20
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
7 EQINT // length multiplierx50 steepness price _18
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
15 PUSHINT // length multiplierx50 steepness price=15
}> // length multiplierx50 steepness price
s3 PUSH // length multiplierx50 steepness price length
8 EQINT // length multiplierx50 steepness price _21
IF:<{ // length multiplierx50 steepness price
DROP // length multiplierx50 steepness
10 PUSHINT // length multiplierx50 steepness price=10
}> // length multiplierx50 steepness price
s0 s3 XCHG // price multiplierx50 steepness length
8 GTINT // price multiplierx50 steepness _24
IF:<{ // price multiplierx50 steepness
5 PUSHINT
s3 POP // price=5 multiplierx50 steepness
}> // price multiplierx50 steepness
s0 s2 PUXC // steepness multiplierx50 steepness price
MUL // steepness multiplierx50 _26
10 PUSHINT // steepness multiplierx50 _26 _27=10
s0 s3 XCHG2 // _26 multiplierx50 _27=10 steepness
SUB // _26 multiplierx50 _28
25 MULCONST // _26 multiplierx50 _30
s1 s2 XCHG // multiplierx50 _26 _30
ADD // multiplierx50 _31
10 PUSHINT // multiplierx50 _31 _32=10
DIV // multiplierx50 price
1000000000 PUSHINT // multiplierx50 price _34=1000000000
MUL // multiplierx50 _35
SWAP // _35 multiplierx50
MUL // _36
50 PUSHINT // _36 _37=50
DIV // _38
}>
get_min_price PROC:<{
// domain_bits_length now_time
SWAP // now_time domain_bits_length
3 RSHIFT# // now_time _5
get_min_price_config CALLDICT // now_time start_min_price end_min_price
SWAP
1000000000 PUSHINT // now_time end_min_price start_min_price _7=1000000000
MUL // now_time end_min_price start_min_price
SWAP
1000000000 PUSHINT // now_time start_min_price end_min_price _9=1000000000
MUL // now_time start_min_price end_min_price
s0 s2 XCHG
1659171600 PUSHINT // end_min_price start_min_price now_time _12=1659171600
SUB // end_min_price start_min_price seconds
2592000 PUSHINT // end_min_price start_min_price seconds _15=2592000
DIV // end_min_price start_min_price months
DUP // end_min_price start_min_price months months
21 GTINT // end_min_price start_min_price months _18
IFJMP:<{ // end_min_price start_min_price months
2DROP // end_min_price
}> // end_min_price start_min_price months
1 2 BLKDROP2 // start_min_price months
REPEAT:<{ // start_min_price
90 MULCONST // _20
100 PUSHINT // _20 _21=100
DIV // start_min_price
}>
}>
force_chain PROC:<{
// addr
REWRITESTDADDR // _8 _9
DROP // wc
0 PUSHINT // wc _5
EQUAL // _6
333 THROWIFNOT
}>
load_data PROC:<{
//
c4 PUSH // _1
CTOS // ds
256 LDU // _5 ds
LDMSGADDR // index collection_address ds
DUP // index collection_address ds ds
SBITS // index collection_address ds _10
0 GTINT // index collection_address ds _12
IFJMP:<{ // index collection_address ds
-1 PUSHINT // index collection_address ds _13=-1
SWAP // index collection_address _13=-1 ds
LDMSGADDR // index collection_address _13=-1 _14 ds
LDREF // index collection_address _13=-1 _14 _16 ds
LDREF // index collection_address _13=-1 _14 _16 _18 ds
LDREF // index collection_address _13=-1 _14 _16 _18 _20 ds
64 LDU // index collection_address _13=-1 _14 _16 _18 _20 _44 _43
DROP // index collection_address _13=-1 _14 _16 _18 _20 _22
s5 s7 XCHG
s5 s6 XCHG // _13=-1 index collection_address _14 _16 _18 _20 _22
}> // index collection_address ds
DROP // index collection_address
0 PUSHINT // index collection_address _25=0
PUSHNULL // index collection_address _25=0 _26
PUSHNULL // index collection_address _25=0 _26 _27
PUSHNULL // index collection_address _25=0 _26 _27 _28
PUSHNULL // index collection_address _25=0 _26 _27 _28 _29
s4 PUSH // index collection_address _25=0 _26 _27 _28 _29 _30=0
s5 s7 XCHG
s5 s6 XCHG // _25=0 index collection_address _26 _27 _28 _29 _30=0
}>
store_data PROC:<{
// index collection_address owner_address content uri domain last_fill_up_time
s0 s6 XCHG
NEWC // last_fill_up_time collection_address owner_address content uri domain index _7
256 STU // last_fill_up_time collection_address owner_address content uri domain _9
s0 s5 XCHG2 // last_fill_up_time domain owner_address content uri _9 collection_address
STSLICER // last_fill_up_time domain owner_address content uri _10
s0 s3 XCHG2 // last_fill_up_time domain uri content _10 owner_address
STSLICER // last_fill_up_time domain uri content _11
STREF // last_fill_up_time domain uri _12
STREF // last_fill_up_time domain _13
STREF // last_fill_up_time _14
64 STU // _16
ENDC // _17
c4 POP
}>
send_msg PROCINLINE:<{
// to_address amount op query_id payload send_mode
0 PUSHINT // to_address amount op query_id payload send_mode _7=0
16 PUSHINT // to_address amount op query_id payload send_mode _7=0 _8=16
NEWC // to_address amount op query_id payload send_mode _7=0 _8=16 _9
6 STU // to_address amount op query_id payload send_mode _7=0 _11
s0 s7 XCHG2 // _7=0 amount op query_id payload send_mode _11 to_address
STSLICER // _7=0 amount op query_id payload send_mode _12
s0 s5 XCHG2 // _7=0 send_mode op query_id payload _12 amount
STVARUINT16 // _7=0 send_mode op query_id payload _13
s1 s5 XCHG // payload send_mode op query_id _7=0 _13
107 STU // payload send_mode op query_id _27
s1 s2 XCHG // payload send_mode query_id op _27
32 STU // payload send_mode query_id _29
64 STU // payload send_mode msg
s2 PUSH // payload send_mode msg payload
ISNULL // payload send_mode msg _32
NOT // payload send_mode msg _33
IF:<{ // payload send_mode msg
ROT // send_mode msg payload
STBR // send_mode msg
SWAP // msg send_mode
}>ELSE<{
s2 POP // msg send_mode
}>
SWAP // send_mode msg
ENDC // send_mode _35
SWAP // _35 send_mode
SENDRAWMSG
}>
transfer_ownership PROCINLINE:<{
// my_balance index collection_address owner_address content uri sender_address query_id in_msg_body fwd_fees domain
s4 POP // my_balance index collection_address owner_address content uri domain query_id in_msg_body fwd_fees
SWAP // my_balance index collection_address owner_address content uri domain query_id fwd_fees in_msg_body
LDMSGADDR // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address in_msg_body
OVER // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address in_msg_body new_owner_address
force_chain CALLDICT
LDMSGADDR // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination in_msg_body
1 LDI // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination _57 _56
NIP // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination in_msg_body
LDVARUINT16 // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount in_msg_body
500000000 PUSHINT // my_balance index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount in_msg_body _25
s1 s13 XCHG // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount my_balance _25
SUB // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount
OVER // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount forward_amount
IF:<{ // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount
s1 s4 PUSH2 // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount forward_amount fwd_fees
ADD // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount _27
SUB // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount
}> // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount
s2 PUSH // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount response_destination
2 PLDU // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount _31
0 NEQINT // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount need_response
DUP // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount need_response need_response
IF:<{ // in_msg_body index collection_address owner_address content uri domain query_id fwd_fees new_owner_address response_destination forward_amount rest_amount need_response
s0 s5 XCHG // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount fwd_fees
SUB // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount
}>ELSE<{
s5 POP // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount
}>
DUP // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount rest_amount
-1 GTINT // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount _37
402 THROWIFNOT
OVER // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount forward_amount
IF:<{ // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount
0x05138d91 PUSHINT // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount _39
NEWC // in_msg_body index collection_address owner_address content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount _39 _40
s0 s11 XCHG2 // in_msg_body index collection_address _39 content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount _40 owner_address
STSLICER // in_msg_body index collection_address _39 content uri domain query_id need_response new_owner_address response_destination forward_amount rest_amount _41
s0 s13 XCHG2 // rest_amount index collection_address _39 content uri domain query_id need_response new_owner_address response_destination forward_amount _41 in_msg_body
STSLICER // rest_amount index collection_address _39 content uri domain query_id need_response new_owner_address response_destination forward_amount _42
1 PUSHINT // rest_amount index collection_address _39 content uri domain query_id need_response new_owner_address response_destination forward_amount _42 _43=1
s4 PUSH
s11 s1 s4 XCHG3
s7 s11 s(-1) PUXC2 // rest_amount index collection_address response_destination content uri domain query_id need_response new_owner_address new_owner_address forward_amount _39 query_id _42 _43=1
send_msg INLINECALLDICT
s6 s9 XCHG // response_destination index collection_address rest_amount content uri domain query_id need_response new_owner_address
}>ELSE<{
s2 s12 XCHG
s9 POP
2DROP // response_destination index collection_address rest_amount content uri domain query_id need_response new_owner_address
}>
SWAP // response_destination index collection_address rest_amount content uri domain query_id new_owner_address need_response
IF:<{ // response_destination index collection_address rest_amount content uri domain query_id new_owner_address
s8 PUSH // response_destination index collection_address rest_amount content uri domain query_id new_owner_address response_destination
force_chain CALLDICT
0xd53276db PUSHINT // response_destination index collection_address rest_amount content uri domain query_id new_owner_address _46
s3 s9 XCHG
s6 s0 s6 XCHG3
PUSHNULL
1 PUSHINT // domain index collection_address new_owner_address content uri response_destination rest_amount _46 query_id _47 _48=1
send_msg INLINECALLDICT
}>ELSE<{
s2 s8 XCHG
s5 POP
2DROP // domain index collection_address new_owner_address content uri
}>
5 ROLL
NOW // index collection_address new_owner_address content uri domain _50
store_data CALLDICT
}>
recv_internal PROC:<{
// msg_value in_msg_full in_msg_body
BALANCE // msg_value in_msg_full in_msg_body _4
FIRST // msg_value in_msg_full in_msg_body my_balance
s0 s2 XCHG // msg_value my_balance in_msg_body in_msg_full
CTOS // msg_value my_balance in_msg_body cs
4 LDU // msg_value my_balance in_msg_body flags cs
SWAP
1 PUSHINT // msg_value my_balance in_msg_body cs flags _12=1
AND // msg_value my_balance in_msg_body cs _13
IFJMP:<{ // msg_value my_balance in_msg_body cs
4 BLKDROP //
}> // msg_value my_balance in_msg_body cs
LDMSGADDR // msg_value my_balance in_msg_body sender_address cs
LDMSGADDR // msg_value my_balance in_msg_body sender_address _238 _237
NIP // msg_value my_balance in_msg_body sender_address cs
LDVARUINT16 // msg_value my_balance in_msg_body sender_address _240 _239
NIP // msg_value my_balance in_msg_body sender_address cs
1 PUSHINT // msg_value my_balance in_msg_body sender_address cs _22=1
SDSKIPFIRST // msg_value my_balance in_msg_body sender_address cs
LDVARUINT16 // msg_value my_balance in_msg_body sender_address _242 _241
NIP // msg_value my_balance in_msg_body sender_address cs
LDVARUINT16 // msg_value my_balance in_msg_body sender_address _244 _243
DROP // msg_value my_balance in_msg_body sender_address fwd_fee
load_data CALLDICT // msg_value my_balance in_msg_body sender_address fwd_fee _245 _246 _247 _248 _249 _250 _251 _252
DROP // msg_value my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri domain
s6 PUSH // msg_value my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri domain init?
NOT // msg_value my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri domain _38
IFJMP:<{ // msg_value my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri domain
4 BLKDROP
s2 POP
s5 POP // msg_value index in_msg_body sender_address fwd_fee collection_address
s0 s2 PUXC // msg_value index in_msg_body collection_address fwd_fee collection_address sender_address
SDEQ // msg_value index in_msg_body collection_address fwd_fee _40
405 THROWIFNOT
s0 s2 XCHG // msg_value index fwd_fee collection_address in_msg_body
LDMSGADDR // msg_value index fwd_fee collection_address from_address in_msg_body
LDREF // msg_value index fwd_fee collection_address from_address domain in_msg_body
LDREF // msg_value index fwd_fee collection_address from_address domain _258 _257
DROP // msg_value index fwd_fee collection_address from_address domain _49
CTOS // msg_value index fwd_fee collection_address from_address domain attachment
LDREF // msg_value index fwd_fee collection_address from_address domain uri attachment
LDREF // msg_value index fwd_fee collection_address from_address domain uri img_uri attachment
LDREF // msg_value index fwd_fee collection_address from_address domain uri img_uri name attachment
LDREF // msg_value index fwd_fee collection_address from_address domain uri img_uri name _266 _265
DROP // msg_value index fwd_fee collection_address from_address domain uri img_uri name description
NEWDICT // msg_value index fwd_fee collection_address from_address domain uri img_uri name description content_dict
s1 s3 XCHG
43884663033947008978309661017057008345326326811558777475113826163084742639165 PUSHINT
SWAP
8 PUSHPOW2 // msg_value index fwd_fee collection_address from_address domain uri description name img_uri _67=43884663033947008978309661017057008345326326811558777475113826163084742639165 content_dict _68=256
DICTUSETREF // msg_value index fwd_fee collection_address from_address domain uri description name content_dict
59089242681608890680090686026688704441792375738894456860693970539822503415433 PUSHINT // msg_value index fwd_fee collection_address from_address domain uri description name content_dict _71=59089242681608890680090686026688704441792375738894456860693970539822503415433
SWAP
8 PUSHPOW2 // msg_value index fwd_fee collection_address from_address domain uri description name _71=59089242681608890680090686026688704441792375738894456860693970539822503415433 content_dict _72=256
DICTUSETREF // msg_value index fwd_fee collection_address from_address domain uri description content_dict
90922719342317012409671596374183159143637506542604000676488204638996496437508 PUSHINT // msg_value index fwd_fee collection_address from_address domain uri description content_dict _75=90922719342317012409671596374183159143637506542604000676488204638996496437508
SWAP
8 PUSHPOW2 // msg_value index fwd_fee collection_address from_address domain uri description _75=90922719342317012409671596374183159143637506542604000676488204638996496437508 content_dict _76=256
DICTUSETREF // msg_value index fwd_fee collection_address from_address domain uri content_dict
0 PUSHINT // msg_value index fwd_fee collection_address from_address domain uri content_dict _79=0
NEWC // msg_value index fwd_fee collection_address from_address domain uri content_dict _79=0 _80
8 STU // msg_value index fwd_fee collection_address from_address domain uri content_dict _82
STDICT // msg_value index fwd_fee collection_address from_address domain uri _83
ENDC // msg_value index fwd_fee collection_address from_address domain uri content
s4 PUSH
s5 s7 XCHG
s0 s4 XCHG
s2 s3 XCHG2
NOW // msg_value collection_address fwd_fee index collection_address from_address content uri domain _85
store_data CALLDICT
s1 s2 XCHG // collection_address msg_value fwd_fee
SUB // collection_address _88
500000000 PUSHINT // collection_address _88 _89
SUB // collection_address rest_amount
DUP // collection_address rest_amount rest_amount
0 GTINT // collection_address rest_amount _92
IF:<{ // collection_address rest_amount
0xd53276db PUSHINT // collection_address rest_amount _93
0 PUSHINT // collection_address rest_amount _93 _94=0
PUSHNULL // collection_address rest_amount _93 _94=0 _95
1 PUSHINT // collection_address rest_amount _93 _94=0 _95 _96=1
send_msg INLINECALLDICT
}>ELSE<{
2DROP //
}>
}> // msg_value my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri domain
s11 POP // domain my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri
s3 s7 PUSH2 // domain my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri collection_address sender_address
SDEQ // domain my_balance in_msg_body sender_address fwd_fee init? index collection_address owner_address content uri _98
s1 s6 XCHG // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content init? _98
AND // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content _99
IFJMP:<{ // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content
s7 s9 XCHG
9 BLKDROP // in_msg_body
LDMSGADDR // _268 _267
DROP // from_address
0 PUSHINT // from_address _103=0
DUP // from_address _103=0 _104=0
LTIME // from_address _103=0 _104=0 _105
PUSHNULL // from_address _103=0 _104=0 _105 _106
64 PUSHINT // from_address _103=0 _104=0 _105 _106 _107=64
send_msg INLINECALLDICT
}> // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content
s7 PUSH // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content in_msg_body
SEMPTY // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content _110
IF:<{ // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content
0 PUSHINT // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content _111=0
}>ELSE<{ // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content
s0 s7 XCHG // domain my_balance content sender_address fwd_fee uri index collection_address owner_address in_msg_body
32 LDU // domain my_balance content sender_address fwd_fee uri index collection_address owner_address _111 in_msg_body
s8 s8 XCHG2 // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content _111
}> // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content op
DUP // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content op op
0 EQINT // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content op _117
IFJMP:<{ // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content op
DROP
s5 POP
s5 POP
s5 POP
s5 POP // domain index collection_address owner_address content uri
5 ROLL
NOW // index collection_address owner_address content uri domain _118
store_data CALLDICT
}> // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content op
s0 s8 XCHG // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content in_msg_body
64 LDU // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
0x5fcc3d14 PUSHINT // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body _124
s10 s(-1) PUXC // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body op _124
EQUAL // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body _125
IFJMP:<{ // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
s9 POP // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content query_id
s7 s2 PUSH2 // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content query_id sender_address owner_address
SDEQ // domain my_balance in_msg_body sender_address fwd_fee uri index collection_address owner_address content query_id _127
401 THROWIFNOT
s9 s10 XCHG
s4 s9 XCHG
s3 s8 XCHG
s7 s6 s0 XCHG3
s4 s1 s3 XCHG3
s0 s2 XCHG // my_balance index collection_address owner_address content uri sender_address query_id in_msg_body fwd_fee domain
transfer_ownership INLINECALLDICT
}> // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
0x1a0b9d51 PUSHINT // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body _130
s10 s(-1) PUXC // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body op _130
EQUAL // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body _131
IFJMP:<{ // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
s6 POP
2DROP
s4 POP
s5 POP
s5 POP // domain index collection_address sender_address owner_address in_msg_body
s2 s1 XCPU // domain index collection_address in_msg_body owner_address sender_address owner_address
SDEQ // domain index collection_address in_msg_body owner_address _133
410 THROWIFNOT
SWAP // domain index collection_address owner_address in_msg_body
LDREF // domain index collection_address owner_address _135 in_msg_body
LDREF // domain index collection_address owner_address _135 _276 _275
DROP // domain index collection_address owner_address _135 _137
5 ROLL
NOW // index collection_address owner_address _135 _137 domain _139
store_data CALLDICT
}> // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
s9 PUSH
1320284409 PUSHINT // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body op _141=1320284409
EQUAL // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body _142
IFJMP:<{ // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
NIP
s6 POP
s7 POP
s7 POP // domain owner_address content sender_address in_msg_body uri index collection_address
s4 s6 XCPU // domain owner_address content collection_address in_msg_body uri index sender_address owner_address
SDEQ // domain owner_address content collection_address in_msg_body uri index _144
411 THROWIFNOT
s0 s2 XCHG // domain owner_address content collection_address index uri in_msg_body
256 LDU // domain owner_address content collection_address index uri key in_msg_body
DUP // domain owner_address content collection_address index uri key in_msg_body in_msg_body
SREFS // domain owner_address content collection_address index uri key in_msg_body _151
0 GTINT // domain owner_address content collection_address index uri key in_msg_body has_value
s0 s6 XCHG // domain owner_address has_value collection_address index uri key in_msg_body content
CTOS // domain owner_address has_value collection_address index uri key in_msg_body cs
8 LDU // domain owner_address has_value collection_address index uri key in_msg_body _157 cs
SWAP // domain owner_address has_value collection_address index uri key in_msg_body cs _157
0 EQINT // domain owner_address has_value collection_address index uri key in_msg_body cs _161
412 THROWIFNOT
LDDICT // domain owner_address has_value collection_address index uri key in_msg_body _282 _281
DROP // domain owner_address has_value collection_address index uri key in_msg_body keyvalue_map
s0 s6 XCHG // domain owner_address keyvalue_map collection_address index uri key in_msg_body has_value
IF:<{ // domain owner_address keyvalue_map collection_address index uri key in_msg_body
LDREF // domain owner_address keyvalue_map collection_address index uri key _284 _283
DROP // domain owner_address keyvalue_map collection_address index uri key value
s0 s1 s5 XCHG3
8 PUSHPOW2 // domain owner_address uri collection_address index value key keyvalue_map _170=256
DICTUSETREF // domain owner_address uri collection_address index keyvalue_map
}>ELSE<{ // domain owner_address keyvalue_map collection_address index uri key in_msg_body
DROP // domain owner_address keyvalue_map collection_address index uri key
s0 s4 XCHG2
8 PUSHPOW2 // domain owner_address uri collection_address index key keyvalue_map _173=256
DICTUDEL // domain owner_address uri collection_address index _285 _286
DROP // domain owner_address uri collection_address index keyvalue_map
}>
0 PUSHINT // domain owner_address uri collection_address index keyvalue_map _175=0
NEWC // domain owner_address uri collection_address index keyvalue_map _175=0 _176
8 STU // domain owner_address uri collection_address index keyvalue_map _178
STDICT // domain owner_address uri collection_address index _179
ENDC // domain owner_address uri collection_address index content
s0 s1 s4 XCHG3
s3 s3 XCHG2
s0 s5 XCHG
NOW // index collection_address owner_address content uri domain _181
store_data CALLDICT
}> // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id in_msg_body
DROP // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id
s8 PUSH
1153347137 PUSHINT // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id op _183=1153347137
EQUAL // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id _184
IFJMP:<{ // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id
s8 POP // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content
80 PUSHINT // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content _186=80
CONFIGOPTPARAM // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content _187
CTOS // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content cs
LDDICT // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content _288 _287
DROP // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config
s4 s(-1) PUXC
8 PUSHPOW2 // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content index config _194=256
DICTUGET
NULLSWAPIFNOT // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_value found
415 THROWIFNOT
8 LDU // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value
OVER // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value config_op
0 EQINT // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value _204
s2 PUSH // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value _204 config_op
1 EQINT // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value _204 _206
OR // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value _207
416 THROWIFNOT
OVER // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value config_op
0 EQINT // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value _210
IF:<{ // domain my_balance query_id sender_address fwd_fee uri index collection_address owner_address content config_op config_value
s4 PUSH
s9 s11 XCHG
s6 s8 XCHG
s0 s7 XCHG
s4 s6 XCHG
s3 s5 XCHG
s4 s10 XCPU
s4 s12 XCHG
s0 s3 XCHG
s0 s13 XCHG // config_op collection_address query_id my_balance index collection_address owner_address content uri sender_address query_id config_value fwd_fee domain
transfer_ownership INLINECALLDICT
s1 s2 XCHG // collection_address config_op query_id
}>ELSE<{
DROP
s3 s10 XCHG
s9 POP
7 BLKDROP // collection_address config_op query_id
}>
SWAP // collection_address query_id config_op
1 EQINT // collection_address query_id _213
IF:<{ // collection_address query_id
0 PUSHINT // collection_address query_id _214=0
923790417 PUSHINT
ROT
PUSHNULL
160 PUSHINT // collection_address _214=0 _215=923790417 query_id _216 _219
send_msg INLINECALLDICT
}>ELSE<{
2DROP //
}>
}> // domain my_balance op sender_address fwd_fee uri index collection_address owner_address content query_id
s5 POP
2DROP
s3 POP
s5 POP
s5 POP // query_id index op sender_address collection_address
0x2fcb26a2 PUSHINT // query_id index op sender_address collection_address _221
s1 s3 XCHG // query_id index collection_address sender_address op _221
EQUAL // query_id index collection_address sender_address _222
IFJMP:<{ // query_id index collection_address sender_address
0 PUSHINT // query_id index collection_address sender_address _223=0
0x8b771735 PUSHINT // query_id index collection_address sender_address _223=0 _224
s0 s4 XCHG
NEWC // query_id _224 collection_address sender_address _223=0 index _225
256 STU // query_id _224 collection_address sender_address _223=0 _227
s0 s3 XCHG2 // query_id _224 _223=0 sender_address _227 collection_address
STSLICER // query_id _224 _223=0 sender_address _228
4 1 REVERSE
64 PUSHINT // sender_address _223=0 _224 query_id _228 _229=64
send_msg INLINECALLDICT
}> // query_id index collection_address sender_address
4 BLKDROP //
16 PUSHPOW2DEC // _231=65535
THROWANY
}>
get_nft_data PROC:<{
//
load_data CALLDICT // _9 _10 _11 _12 _13 _14 _15 _16
s2 s3 XCHG
3 BLKDROP // init? index collection_address owner_address uri
}>
get_editor PROC:<{
//
load_data CALLDICT // _9 _10 _11 _12 _13 _14 _15 _16
s4 s7 XCHG
7 BLKDROP // owner_address
}>
get_domain PROC:<{
//
load_data CALLDICT // _10 _11 _12 _13 _14 _15 _16 _17
s1 s7 XCHG
7 BLKDROP // domain
CTOS // _9
}>
get_last_fill_up_time PROC:<{
//
load_data CALLDICT // _9 _10 _11 _12 _13 _14 _15 _16
7 1 BLKDROP2 // last_fill_up_time
}>
dnsresolve PROC:<{
// subdomain category
OVER // subdomain category subdomain
SBITS // subdomain category subdomain_bits
DUP
8 PUSHINT // subdomain category subdomain_bits subdomain_bits _5=8
MOD // subdomain category subdomain_bits _6
0 EQINT // subdomain category subdomain_bits _8
70 THROWIFNOT
load_data CALLDICT // subdomain category subdomain_bits _49 _50 _51 _52 _53 _54 _55 _56
s3 s7 XCHG
7 BLKDROP // subdomain category subdomain_bits content
CTOS // subdomain category subdomain_bits cs
8 LDU // subdomain category subdomain_bits _22 cs
SWAP // subdomain category subdomain_bits cs _22
0 EQINT // subdomain category subdomain_bits cs _26
412 THROWIFNOT
LDDICT // subdomain category subdomain_bits _60 _59
DROP // subdomain category subdomain_bits keyvalue_map
s0 s3 XCHG // keyvalue_map category subdomain_bits subdomain
8 PLDI // keyvalue_map category subdomain_bits _33
0 EQINT // keyvalue_map category subdomain_bits starts_with_zero_byte
413 THROWIFNOT
8 GTINT // keyvalue_map category _39
IF:<{ // keyvalue_map category
DROP // keyvalue_map
11732114750494247458678882651681748623800183221773167493832867265755123357695 PUSHINT // keyvalue_map category=11732114750494247458678882651681748623800183221773167493832867265755123357695
}> // keyvalue_map category
DUP // keyvalue_map category category
0 EQINT // keyvalue_map category _42
IFJMP:<{ // keyvalue_map category
DROP // keyvalue_map
8 PUSHINT // keyvalue_map _43=8
SWAP // _43=8 keyvalue_map
}> // keyvalue_map category
SWAP
8 PUSHPOW2 // category keyvalue_map _46=256
DICTUGETREF // _61 _62
DROP // value
8 PUSHINT // value _48=8
SWAP // _48=8 value
}>
}END>c

1
build/wrapper.compiled.json

@ -0,0 +1 @@
{"hex":"b5ee9c72c10107010086000d12161b207a860114ff00f4a413f4bcf2c80b0102012003020004f23002014805040005a0734b01aed0edfb6c2220c70094840ff2f0ded31f3001d0d3030171b0915be0fa4030db3c3031c7058e2e82105fcc3d145210ba82101c04412a5220bab19330db31e08210140aec515210ba9330db31e082104eb110a9ba309130e2060014ed44d0fa40fa40fa403007143f6e"}

136
build/wrapper.fif

@ -0,0 +1,136 @@
"Asm.fif" include
// automatically generated from `contracts/wrapper.fc` incl:`contracts/imports/stdlib.fc` incl:`contracts/imports/constants.fc` incl:`contracts/imports/utils.fc` incl:`contracts/imports/op-codes.fc`
PROGRAM{
DECLPROC send_grams
DECLPROC load_data
DECLPROC store_data
DECLPROC recv_internal
DECLPROC send_msg
DECLPROC recv_external
80293 DECLMETHOD get_owner
send_grams PROC:<{
// address amount
0 PUSHINT // address amount _3=0
24 PUSHINT // address amount _3=0 _4=24
NEWC // address amount _3=0 _4=24 _5
6 STU // address amount _3=0 _7
s0 s3 XCHG2 // _3=0 amount _7 address
STSLICER // _3=0 amount _8
SWAP // _3=0 _8 amount
STGRAMS // _3=0 _9
107 STU // _11
ENDC // msg
3 PUSHINT // msg _13=3
SENDRAWMSG
}>
load_data PROCREF:<{
//
c4 PUSH // _1
CTOS // ds
LDMSGADDR // target ds
LDMSGADDR // target owner ds
LDMSGADDR // target owner _17 _16
DROP // target owner agorata
}>
store_data PROCREF:<{
// target owner agorata
NEWC // target owner agorata _3
s0 s3 XCHG2 // agorata owner _3 target
STSLICER // agorata owner _4
SWAP // agorata _4 owner
STSLICER // agorata _5
SWAP // _5 agorata
STSLICER // _6
ENDC // _7
c4 POP
}>
recv_internal PROC:<{
SAMEALTSAVE // my_balance msg_value in_msg_full in_msg_body
2 2 BLKDROP2 // in_msg_full in_msg_body
DUP // in_msg_full in_msg_body in_msg_body
SEMPTY // in_msg_full in_msg_body _4
IF:<{ // in_msg_full in_msg_body
16 PUSHPOW2DEC // in_msg_full in_msg_body _5=65535
THROWANY
}> // in_msg_full in_msg_body
32 LDU // in_msg_full _37 _36
DROP // in_msg_full op
SWAP // op in_msg_full
CTOS // op cs
4 LDU // op flags cs
SWAP
1 PUSHINT // op cs flags _17=1
AND // op cs _18
IFJMP:<{ // op cs
2DROP //
}> // op cs
LDMSGADDR // op _41 _40
DROP // op sender_address
load_data INLINECALLDICT // op sender_address _42 _43 _44
DROP
NIP // op sender_address owner
SDEQ // op _26
IF:<{ // op
0x5fcc3d14 PUSHINT // op _27
s1 s(-1) PUXC // op op _27
EQUAL // op _28
0x1c04412a PUSHINT // op _28 _29
s2 s(-1) PUXC // op _28 op _29
EQUAL // op _28 _30
OR // op _31
IFJMP:<{ // op
DROP //
RETALT
}> // op
0x140aec51 PUSHINT // op _32
s1 s(-1) PUXC // op op _32
EQUAL // op _33
IFJMP:<{ // op
DROP //
RETALT
}> // op
0x4eb110a9 PUSHINT // op _34
EQUAL // _35
DROP //
}>ELSE<{
DROP //
}>
}>
send_msg PROCINLINE:<{
// to_address amount op query_id payload send_mode
0 PUSHINT // to_address amount op query_id payload send_mode _7=0
16 PUSHINT // to_address amount op query_id payload send_mode _7=0 _8=16
NEWC // to_address amount op query_id payload send_mode _7=0 _8=16 _9
6 STU // to_address amount op query_id payload send_mode _7=0 _11
s0 s7 XCHG2 // _7=0 amount op query_id payload send_mode _11 to_address
STSLICER // _7=0 amount op query_id payload send_mode _12
s0 s5 XCHG2 // _7=0 send_mode op query_id payload _12 amount
STVARUINT16 // _7=0 send_mode op query_id payload _13
s1 s5 XCHG // payload send_mode op query_id _7=0 _13
107 STU // payload send_mode op query_id _27
s1 s2 XCHG // payload send_mode query_id op _27
32 STU // payload send_mode query_id _29
64 STU // payload send_mode msg
s2 PUSH // payload send_mode msg payload
ISNULL // payload send_mode msg _32
NOT // payload send_mode msg _33
IF:<{ // payload send_mode msg
ROT // send_mode msg payload
STBR // send_mode msg
SWAP // msg send_mode
}>ELSE<{
s2 POP // msg send_mode
}>
SWAP // send_mode msg
ENDC // send_mode _35
SWAP // _35 send_mode
SENDRAWMSG
}>
recv_external PROC:<{
// in_msg_body
DROP //
}>
get_owner PROC:<{
//
}>
}END>c

90
contracts/imports/dns-utils.fc

@ -87,7 +87,7 @@ int check_domain_string(slice domain) {
result1~store_uint(char, 8);
}
if (~ need_break & (i >= len)) {
throw(259); ;; no ';' found
throw(259); ;; no ';' found
}
}
} until (need_break);
@ -102,48 +102,49 @@ int check_domain_string(slice domain) {
int len = slice_bits(str);
int need_break = 0;
builder result = begin_cell();
do {
int res_len = 0;
while ~ need_break {
need_break = len == 0;
if (~ need_break) {
int char = str~load_uint(8);
int byte = 0;
if (char >= 65) {
if (char <= 90) { ;; a-z -> 0-25
byte = char - 65;
if ((char >= 65) & (char <= 90)) {
;; Code for A-Z -> 0-25
byte = char - 65;
} else {
if ((char >= 97) & (char <= 122)) {
;; Code for a-z -> 26-51
byte = char - 71;
} else {
if (char >= 97) { ;; A-Z -> 26-51
if (char <= 122) {
byte = char - 71;
if ((char >= 48) & (char <= 57)) {
;; Code for 0-9 -> 52-61
byte = char + 4;
} else {
if (char == 45) {
;; Code for - -> 62
byte = 62;
} else {
if (char >= 48) { ;; 0-9 -> 52-61
if (char <= 57) {
byte = char + 4;
} else {
if (char == 45) { ;; - -> 62
byte = 62;
} else {
if (char == 95) { ;; _ -> 63
byte = 63;
} else {
throw(260); ;; invalid character
}
}
}
if (char == 95) {
;; Code for _ -> 63
byte = 63;
} else {
throw(260); ;; invalid character
throw(260); ;; invalid character
}
}
} else {
throw(260); ;; invalid character
}
}
} else {
throw(260); ;; invalid character
}
result~store_uint(byte, 6);
len -= 8;
if (len > 0) {
result~store_uint(byte, 6);
} else {
;; Last byte
result~store_uint(byte, 8 - mod(res_len, 8));
}
res_len += 6;
}
} until (need_break);
}
return result.end_cell().begin_parse();
}
@ -172,6 +173,37 @@ int check_domain_string(slice domain) {
return (10, 1);
}
int price_function(int length, int multiplierx50, int steepness) {
;; length is the length of the domain, the price depends on it. The rest is the price config
;; multiplierx50 is the price multiplier, the default price is multiplied by multiplierx50 / 50
;; steepness (from 0 to 10) is the steepness of the price function,
;; 10 means the distribution is as in the function from `get_min_price_config` (the second number), 0 means the price is always the same, 50
int price = 25;
if (length == 3) {
price = 100;
}
if (length == 4) {
price = 50;
}
if (length == 5) {
price = 25;
}
if (length == 6) {
price = 20;
}
if (length == 7) {
price = 15;
}
if (length == 8) {
price = 10;
}
if (length >= 9) {
price = 5;
}
price = (steepness * price + (10 - steepness) * 25) / 10;
return price * one_ton * multiplierx50 / 50;
}
int get_min_price(int domain_bits_length, int now_time) {
(int start_min_price, int end_min_price) = get_min_price_config(domain_bits_length / 8);
start_min_price *= one_ton;

1
contracts/imports/op-codes.fc

@ -19,6 +19,7 @@ int op::editorship_assigned() asm "0x511a4463 PUSHINT";
int op::new_nft() asm "0x1a039a51 PUSHINT";
int op::instant_buy_new_nft() asm "0x16c7d435 PUSHINT";
int op::init_after_buy() asm "0x437dc408 PUSHINT";
int op::collect_money() asm "0x2a0c8a20 PUSHINT";
;; DNS
const int op::fill_up = 0x370fec51;

345
contracts/main.ts

@ -1,16 +1,26 @@
import BN from "bn.js";
import { Cell, beginCell, Address } from "ton";
import { C7Config, SmartContract } from "ton-contract-executor";
import {encodeOffChainContent, makeSnakeCell} from "./utils";
import { randomBytes } from "crypto";
import { keyPairFromSeed, KeyPair, sign } from "ton-crypto";
import { ExpansionPanelActions } from "@material-ui/core";
import {Cell, beginCell, Address, Slice, TonClient} from "ton";
import {SmartContract} from "ton-contract-executor";
import {
AdnlAddress, bytesToBase64,
categoryToBN,
decodeOffChainContent,
encodeOffChainContent,
encodeSemiChainContent,
makeSnakeCell
} from "./utils";
import {randomBytes} from "crypto";
import {keyPairFromSeed, KeyPair, sign, keyPairFromSecretKey, sha256} from "ton-crypto";
import {hex as item_code} from "../build/nft-item.compiled.json";
import {randomAddress} from "../test/helpers";
import {hashCell} from "ton/dist/boc/boc";
import {Base64} from "@tonconnect/protocol";
// encode contract storage according to save_data() contract method
export function genKeyPair(): KeyPair {
let seed = randomBytes(32);
return keyPairFromSeed(seed);
let seed = randomBytes(32);
return keyPairFromSeed(seed);
}
// nft_item_code:^Cell
@ -22,89 +32,288 @@ export function genKeyPair(): KeyPair {
// cell auction - auction info
// int64 last_fill_up_time
export function data(params: { ownerAddress: Address; collectionAddress: Address, code: Cell, domain: String, publicKey: Buffer }): Cell {
let data_cell = beginCell()
// For code: https://github.com/getgems-io/nft-contracts/blob/main/packages/contracts/sources/nft-auction/build.sh
.storeRef(params.code)
.storeUint(0, 256)
.storeAddress(params.collectionAddress)
.storeAddress(params.ownerAddress)
.storeRef(encodeOffChainContent("https://agorata.io/collection.json")) // https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md
.storeRef(makeSnakeCell(Buffer.from(params.domain)))
.storeDict(null)
.storeUint(0, 64).endCell();
let data_cell = beginCell()
// For code: https://github.com/getgems-io/nft-contracts/blob/main/packages/contracts/sources/nft-auction/build.sh
.storeRef(params.code)
.storeUint(0, 256)
.storeAddress(params.collectionAddress)
.storeAddress(params.ownerAddress)
.storeRef(encodeOffChainContent(`https://api.agorata.io/collection/${params.domain}.json`)) // https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md
.storeRef(makeSnakeCell(Buffer.from(params.domain)))
.storeDict(null)
.storeUint(0, 64).endCell();
return beginCell().storeRef(data_cell).storeBuffer(params.publicKey).endCell();
return beginCell().storeRef(data_cell).storeBuffer(params.publicKey).endCell();
}
export function collectionData(params: { code: Cell, ownerAddress: Address, ownerKey: number }): Cell {
function strCell(str: string): Cell {
return beginCell().storeBuffer(Buffer.from(str)).endCell();
}
export function collectionData(params: {
code: Cell, ownerAddress: Address, ownerKey: BN,
price_multiplier?: number, price_steepness?: number, zone?: string
}): Cell {
if (params.price_multiplier == undefined) {
params.price_multiplier = 1;
}
if (params.price_steepness == undefined) {
params.price_steepness = 0;
}
if (params.zone == undefined) {
params.zone = "example.ton";
}
return beginCell()
.storeRef(encodeOffChainContent("https://agorata.io/collection.json"))
.storeRef(encodeOffChainContent(`https://api.agorata.io/data/${params.zone}.json`)) // https://github.com/ton-blockchain/TEPs/blob/master/text/0064-token-data-standard.md
.storeRef(params.code)
.storeRef(beginCell().endCell())
.storeRef(beginCell().storeUint(params.price_multiplier, 8).storeUint(params.price_steepness, 4).endCell())
.storeUint(params.ownerKey, 256)
.storeAddress(params.ownerAddress)
.endCell();
.storeRef(
beginCell()
.storeRef(strCell(`https://api.agorata.io/data/${params.zone}/`))
.storeRef(beginCell().storeRef(strCell(`.json`))
.storeRef(strCell(`.png`)).endCell())
.storeRef(strCell('.' + params.zone))
.storeRef(strCell(`A TON DNS domain in the ${params.zone} zone. By agorata.io`))
.endCell())
.endCell();
}
export function itemDataUninit(params: { domain: String, collectionAddress: Address }): Cell {
let domain = params.domain.split('.')[0];
let index = new BN(hashCell(makeSnakeCell(Buffer.from(domain))));
return beginCell()
.storeUint(index, 256)
.storeAddress(params.collectionAddress).endCell();
}
export async function itemData(params: {
domain: String, collectionAddress: Address,
ownerAddress: Address
}): Promise<Cell> {
let domain = params.domain.split('.')[0];
let zone = params.domain.split('.').slice(1).join('.');
let index = new BN(hashCell(makeSnakeCell(Buffer.from(domain))));
return beginCell()
.storeUint(index, 256)
.storeAddress(params.collectionAddress)
.storeAddress(params.ownerAddress)
.storeRef(await itemContent(domain, zone))
.storeRef(makeSnakeCell(Buffer.from(domain)))
.storeUint(0, 64).endCell();
}
export async function getRecords(tonclient: TonClient, address: Address) {
let wallet = null;
try {
let ans_wallet = (await tonclient.callGetMethod(address, 'dnsresolve',
[["tvm.Slice", "te6cckEBAQEAAwAAAgDTZ9xB"],
["num", new BN(await sha256('wallet')).toString()]])).stack[1];
if (ans_wallet[1].bytes !== undefined) {
let reader = Cell.fromBoc(Buffer.from(ans_wallet[1].bytes, 'base64'))[0].beginParse()
reader.skip(16);
wallet = reader.readAddress()?.toFriendly();
}
} catch (e) {
}
let site = null;
try {
let ans_site = (await tonclient.callGetMethod(address, 'dnsresolve',
[["tvm.Slice", "te6cckEBAQEAAwAAAgDTZ9xB"],
["num", new BN(await sha256('site')).toString()]])).stack[1];
if (ans_site[1].bytes !== undefined) {
let site_data = ans_site[1].bytes; // object.data.b64;
// print site_data converted from base64
let c = Cell.fromBoc(Buffer.from(site_data, 'base64'))[0].beginParse();
c.skip(16);
site = new AdnlAddress(c.readRemainingBytes().subarray(0, 32)).toHex();
}
} catch (e) {
console.log(e)
}
let uri = null;
try {
let ans_uri = (await tonclient.callGetMethod(address, 'dnsresolve',
[["tvm.Slice", "te6cckEBAQEAAwAAAgDTZ9xB"],
["num", new BN(await sha256('uri')).toString()]])).stack[1];
uri = Cell.fromBoc(Buffer.from(ans_uri[1].bytes, "base64"))[0].beginParse().readRemainingBytes().toString();
} catch (e) {
// console.log((await tonclient.callGetMethod(address, 'get_nft_data')).stack[4]);
}
// let name_uri = (await tonclient.callGetMethod(address, 'dnsresolve',
// [["tvm.Slice", "te6cckEBAQEAAwAAAgDTZ9xB"],
// ["num", new BN(await sha256('image')).toString()]])).stack[1];
// console.log(Cell.fromBoc(Buffer.from(name_uri[1].bytes, "base64"))[0].beginParse().readRemainingBytes().toString());
return {wallet, site, uri};
}
export async function getPrice(tonclient: TonClient, address: Address, subdomain: string) {
let price = (await tonclient.callGetMethod(address, 'get_price',
[["tvm.Slice", bytesToBase64(beginCell().storeBuffer(Buffer.from(subdomain)).endCell().toBoc())]]));
// like "0x1dcd6500". Need to convert it to number
let price_hex = price.stack[0][1];
return parseInt(price_hex.slice(2), 16);
}
export function setContractBalance(contract: SmartContract, balance: number, address?: Address) {
if (address == undefined) {
address = randomAddress("collection");
}
contract.setC7Config({balance: balance, myself: address});
}
export function asciiEncode(buf: Buffer): string {
let sl = beginCell().storeBuffer(buf).endCell().beginParse();
let result = "";
while (sl.remaining) {
let byte;
if (sl.remaining >= 6) {
byte = sl.readUint(6).toNumber();
} else {
byte = sl.readUint(sl.remaining).toNumber();
}
if (byte < 26) {
result += String.fromCharCode(byte + 65); // 0-25 -> A-Z
} else if (byte < 52) {
result += String.fromCharCode(byte + 97 - 26); // 26-51 -> a-z
} else if (byte < 62) {
result += String.fromCharCode(byte + 48 - 52); // 52-61 -> 0-9
} else if (byte == 62) {
result += '-'; // 62 -> -
} else if (byte == 63) {
result += '_'; // 63 -> _
}
}
return result;
}
export function auctionWithWinner(winnerAddress: Address) {
return beginCell().storeAddress(winnerAddress).storeCoins(0).storeUint(0, 64)
export function signBuy(domain: string, collectionAddress: Address, buyerAddress: Address, ownerKey: Buffer): string {
let signData = beginCell().storeAddress(collectionAddress).storeBuffer(Buffer.from(domain))
.storeAddress(buyerAddress).storeUint(0, 2).endCell();
let signature = sign(hashCell(signData), ownerKey);
return asciiEncode(signature);
}
export function setContractBalance(contract: SmartContract, balance: number) {
contract.setC7Config({balance: balance});
export function getItemAddr(collectionAddress: Address, domain: string, workchain: number): Address {
let item_data_init = beginCell()
.storeUint(new BN(hashCell(beginCell().storeBuffer(Buffer.from(domain)).endCell())), 256)
.storeAddress(collectionAddress).endCell();
let item_state_init = beginCell().storeUint(0, 2)
.storeDict(Cell.fromBoc(item_code)[0])
.storeDict(item_data_init)
.storeUint(0, 1).endCell();
return new Address(workchain, hashCell(item_state_init));
}
export function TON(): number { return 1000000000; }
export function TON(): number {
return 1000000000;
}
export async function changeRecordMsg(category: string, value: Cell | null) {
let cell = beginCell()
.storeUint(0x4eb1f0f9, 32)
.storeUint(0, 64)
.storeUint(new BN(await categoryToBN(category)), 256);
if (value) {
cell.storeRef(value);
}
return cell.endCell();
}
export async function AdnlRecord(site: AdnlAddress) {
return beginCell()
.storeUint(0xad01, 16)
.storeBuffer(<Buffer>site.bytes)
.storeUint(0, 8).endCell();
}
export async function WalletRecord(wallet: Address) {
return beginCell()
.storeUint(0x9fd3, 16)
.storeAddress(wallet)
.storeUint(0, 8).endCell();
}
// message encoders for all ops (see contracts/imports/constants.fc for consts)
export function transferOwnership(params: { newOwnerAddress: Address }): Cell {
return beginCell().storeUint(0x5fcc3d14, 32).storeUint(0, 64).storeAddress(params.newOwnerAddress).storeAddress(null).storeInt(0, 1).storeCoins(1 * TON()).endCell();
return beginCell().storeUint(0x5fcc3d14, 32).storeUint(0, 64).storeAddress(params.newOwnerAddress).storeAddress(null).storeInt(0, 1).storeCoins(1 * TON()).endCell();
}
export function createItem(params: { domain: String, signature?: String }): Cell {
if (params.signature == undefined) {
params.signature = "000";
}
return beginCell()
.storeUint(0, 32)
.storeRef(makeSnakeCell(Buffer.from(params.domain + ';' + params.signature)))
.endCell();
}
export function initializeItemMsg(params: { domain: String, ownerAddr: Address, zone: String }): Cell {
return beginCell()
.storeAddress(params.ownerAddr)
.storeRef(beginCell().storeBuffer(Buffer.from(params.domain)).endCell())
.storeRef(beginCell()
.storeRef(strCell(`https://api.agorata.io/data/${params.zone}/${params.domain}.json`))
.storeRef(strCell(`https://api.agorata.io/data/${params.zone}/${params.domain}.png`))
.storeRef(strCell(`${params.zone}.${params.domain}`))
.storeRef(strCell(`A TON DNS domain in the ${params.zone} zone`))
.endCell()
)
.endCell();
}
export function createItem(params: { domain: String }): Cell {
let signature = '000';
return beginCell()
.storeUint(0, 32)
.storeRef(makeSnakeCell(Buffer.from(params.domain + ';' + signature)))
.endCell();
async function itemContent(domain: string, zone: string): Promise<Cell> {
return await encodeSemiChainContent(`https://api.agorata.io/data/${zone}/${domain}.json`)
}
export async function setContent(params: { domain: string, zone: string }) {
// return beginCell()
// .storeUint(0x1a0b9d51, 32)
// .storeUint(0, 64)
// .storeRef(await itemContent(params.domain, params.zone))
// .endCell();
return changeRecordMsg("uri", beginCell().storeBuffer(Buffer.from(`https://api.agorata.io/data/${params.zone}/${params.domain}.json`)).endCell());
}
export function instantBuySignature(receiverAddress: Address, issuedCollectionAddr: Address, amount: number, domain: Cell, privateKey: Buffer): Buffer {
let messageToSign = beginCell().storeAddress(receiverAddress).storeAddress(issuedCollectionAddr).storeUint(amount, 256).storeRef(domain).endCell();
let hash = messageToSign.hash();
// console.log(hash.toString("hex"));
// console.log((new BN(hash)).toString(10))
// return sign(hash, privateKey);
let althash = new BN("FF11841721E4DAD5AE679A1A338B2EBFC5AAF7529C200B4EF9D71831B1DCB969", "hex");
return sign(althash.toBuffer(), privateKey);
}
export function instantBuyMessage(params: { receiverAddress: Address, issuedCollectionAddr: Address, price: number, domain: String, privateKey: Buffer}): Cell {
let domainSnakeCell = makeSnakeCell(Buffer.from(params.domain));
let signature = instantBuySignature(params.receiverAddress, params.issuedCollectionAddr, params.price, domainSnakeCell, params.privateKey);
console.log(signature.toString("hex").toUpperCase());
let cell = beginCell()
.storeUint(0x16c7d435, 32) // opcode
.storeUint(0, 64) // query id
.storeBuffer(signature) // body
.storeUint(params.price, 256)
.storeRef(domainSnakeCell).endCell();
return cell;
let messageToSign = beginCell().storeAddress(receiverAddress).storeAddress(issuedCollectionAddr).storeUint(amount, 256).storeRef(domain).endCell();
let hash = messageToSign.hash();
// console.log(hash.toString("hex"));
// console.log((new BN(hash)).toString(10))
// return sign(hash, privateKey);
let althash = new BN("FF11841721E4DAD5AE679A1A338B2EBFC5AAF7529C200B4EF9D71831B1DCB969", "hex");
return sign(althash.toBuffer(), privateKey);
}
export function instantBuyMessage(params: { receiverAddress: Address, issuedCollectionAddr: Address, price: number, domain: String, privateKey: Buffer }): Cell {
let domainSnakeCell = makeSnakeCell(Buffer.from(params.domain));
let signature = instantBuySignature(params.receiverAddress, params.issuedCollectionAddr, params.price, domainSnakeCell, params.privateKey);
console.log(signature.toString("hex").toUpperCase());
let cell = beginCell()
.storeUint(0x16c7d435, 32) // opcode
.storeUint(0, 64) // query id
.storeBuffer(signature) // body
.storeUint(params.price, 256)
.storeRef(domainSnakeCell).endCell();
return cell;
}
export function currentState(contract: SmartContract) {
let c4 = contract.dataCell.beginParse();
let reader = c4.readRef();
return {
nft_item_code: reader.readRef(),
index: reader.readUint(256),
collectionAddress: reader.readAddress(),
ownerAddress: reader.readAddress(),
collectionContent: reader.readRef(),
domain: reader.readRef(),
// auction: reader.readCell(), – TODO: still havent's figured out to load auction here
// lastFillUpTime: reader.readInt(64)
}
let c4 = contract.dataCell.beginParse();
let reader = c4.readRef();
return {
nft_item_code: reader.readRef(),
index: reader.readUint(256),
collectionAddress: reader.readAddress(),
ownerAddress: reader.readAddress(),
collectionContent: reader.readRef(),
domain: reader.readRef(),
// auction: reader.readCell(), – TODO: still havent's figured out to load auction here
// lastFillUpTime: reader.readInt(64)
}
}

95
contracts/nft-collection.fc

@ -3,8 +3,6 @@
#include "imports/op-codes.fc";
#include "imports/params.fc";
;; -1 if needed, 0 if not
const signature_needed = 0;
;; storage scheme
;; cell collection_content
@ -12,25 +10,32 @@ const signature_needed = 0;
;; cell pricing
;; uint256(key) owner_key
;; address owner_address
;; cell data_scheme:
;; uri prefix for image and data slice as a cell
;; cell: uri postfix ('.json') slice as a cell, image uri postfix ('.png')
;; zone
;; description
(cell, cell, cell, int, slice) load_data() inline {
(cell, cell, cell, int, slice, cell) load_data() inline {
var ds = get_data().begin_parse();
return (
ds~load_ref(), ;; content
ds~load_ref(), ;; nft_item_code
ds~load_ref(), ;; pricing
ds~load_ref(), ;; pricing
ds~load_uint(256), ;; owner key
ds~load_msg_addr() ;; owner address
ds~load_msg_addr(), ;; owner address
ds~load_ref() ;; data_scheme
);
}
() save_data(cell content, cell nft_item_code, cell pricing, int owner_key, slice owner_addr) impure inline {
() save_data(cell content, cell nft_item_code, cell pricing, int owner_key, slice owner_addr, cell data_scheme) impure inline {
set_data(begin_cell()
.store_ref(content)
.store_ref(nft_item_code)
.store_ref(pricing)
.store_uint(owner_key, 256)
.store_slice(owner_addr)
.store_ref(data_scheme)
.end_cell());
}
@ -41,7 +46,10 @@ int calcprice(slice domain, cell pricing) inline_ref {
throw_unless(201, len <= 126 * 8); ;; maxmimum 126 characters
throw_unless(202, mod(len, 8) == 0);
throw_unless(203, check_domain_string(domain));
return 100000; ;; todo
slice pr = pricing.begin_parse();
int multiplier = pr~load_uint(8);
int steepness = pr~load_uint(4);
return price_function(len / 8, multiplier, steepness);
}
cell calculate_nft_item_state_init(int item_index, cell nft_item_code) {
@ -49,6 +57,28 @@ cell calculate_nft_item_state_init(int item_index, cell nft_item_code) {
return begin_cell().store_uint(0, 2).store_dict(nft_item_code).store_dict(data).store_uint(0, 1).end_cell();
}
cell get_attachment(slice domain, cell data_scheme) {
;; parse the prefix and the postfix out of data_scheme
slice cs = data_scheme.begin_parse();
slice prefix = cs~load_ref().begin_parse();
slice postfixes = cs~load_ref().begin_parse();
slice postfix = postfixes~load_ref().begin_parse();
slice image_postfix = postfixes~load_ref().begin_parse();
;; create the slice with the uri: prefix + domain + postfix
cell uri_cell = begin_cell().store_uint(1, 8).store_slice(prefix).store_slice(domain).store_slice(postfix).end_cell();
cell image_uri_cell = begin_cell().store_slice(prefix).store_slice(domain).store_slice(image_postfix).end_cell();
slice zone = cs~load_ref().begin_parse();
cell name_cell = begin_cell().store_slice(domain).store_slice(zone).end_cell();
cell desc_cell = cs~load_ref();
cell full_cell = begin_cell()
.store_ref(uri_cell)
.store_ref(image_uri_cell)
.store_ref(name_cell)
.store_ref(desc_cell)
.end_cell();
return full_cell;
}
slice calculate_nft_item_address(int wc, cell state_init) {
return begin_cell()
.store_uint(4, 3)
@ -58,7 +88,23 @@ slice calculate_nft_item_address(int wc, cell state_init) {
.begin_parse();
}
() deploy_nft_item(int item_index, cell nft_item_code, cell nft_content) impure {
() send_msg(slice to_address, int amount, int op, int query_id, builder payload, int send_mode) impure inline {
var msg = begin_cell()
.store_uint(0x10, 6) ;; nobounce - int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool src:MsgAddress -> 010000
.store_slice(to_address)
.store_coins(amount)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
.store_uint(op, 32)
.store_uint(query_id, 64);
if (~ builder_null?(payload)) {
msg = msg.store_builder(payload);
}
send_raw_message(msg.end_cell(), send_mode);
}
() deploy_nft_item(int item_index, cell nft_item_code, cell nft_payload) impure {
cell state_init = calculate_nft_item_state_init(item_index, nft_item_code);
slice nft_address = calculate_nft_item_address(workchain(), state_init);
var msg = begin_cell()
@ -67,12 +113,13 @@ slice calculate_nft_item_address(int wc, cell state_init) {
.store_coins(0)
.store_uint(4 + 2 + 1, 1 + 4 + 4 + 64 + 32 + 1 + 1 + 1)
.store_ref(state_init)
.store_ref(nft_content);
.store_ref(nft_payload);
send_raw_message(msg.end_cell(), 64); ;; carry all the remaining value of the inbound message, fee deducted from amount
}
int verify_signature(slice signature, slice sender_address, slice domain, int owner_key) {
cell option_data = begin_cell().store_slice(my_address()).store_slice(domain).store_slice(sender_address).end_cell();
cell option_data = begin_cell().store_slice(my_address())
.store_slice(domain).store_slice(sender_address).store_uint(0, 2).end_cell();
return check_signature(slice_hash(option_data.begin_parse()), signature, owner_key);
}
@ -89,7 +136,7 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
int op = in_msg_body~load_uint(32);
var (content, nft_item_code, pricing, key, addr) = load_data();
var (content, nft_item_code, pricing, key, addr, data_scheme) = load_data();
if (op == 0) { ;; deploy new nft
int now_time = now();
@ -102,7 +149,7 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
int item_index = slice_hash(domain);
slice sender_address = cs~load_msg_addr();
if (signature_needed) {
if (key != 0) {
slice signature = decode_asciicode(signature_encoded);
throw_unless(205, verify_signature(signature, sender_address, domain, key));
}
@ -110,6 +157,7 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
cell nft_content = begin_cell()
.store_slice(sender_address)
.store_ref(begin_cell().store_slice(domain).end_cell())
.store_ref(get_attachment(domain, data_scheme))
.end_cell();
deploy_nft_item(item_index, nft_item_code, nft_content);
return ();
@ -118,18 +166,25 @@ int verify_signature(slice signature, slice sender_address, slice domain, int ow
if (op == op::fill_up) { ;; just fill-up balance
return ();
}
if (op == op::collect_money()) {
slice sender_address = cs~load_msg_addr();
throw_unless(403, equal_slices(sender_address, addr));
send_msg(addr, msg_value, op::collect_money(), 0, null(), 1);
return ();
}
throw(0xffff);
}
;; Get methods
(int, cell, slice) get_collection_data() method_id {
var (content, nft_item_code, pricing, key, addr) = load_data();
var (content, nft_item_code, pricing, key, addr, data_scheme) = load_data();
return (-1, content, zero_address());
}
slice get_nft_address_by_index(int index) method_id {
var (content, nft_item_code, pricing, key, addr) = load_data();
var (content, nft_item_code, pricing, key, addr, data_scheme) = load_data();
cell state_init = calculate_nft_item_state_init(index, nft_item_code);
return calculate_nft_item_address(workchain(), state_init);
}
@ -138,13 +193,23 @@ cell get_nft_content(int index, cell individual_nft_content) method_id {
return individual_nft_content;
}
int get_price(slice domain) method_id {
var (content, nft_item_code, pricing, key, addr, data_scheme) = load_data();
return calcprice(domain, pricing);
}
int signature_data(slice sender_address, slice domain) method_id {
cell option_data = begin_cell().store_slice(my_address()).store_slice(domain).store_slice(sender_address).end_cell();
return slice_hash(option_data.begin_parse());
}
(int, cell) dnsresolve(slice subdomain, int category) method_id {
throw_unless(70, mod(slice_bits(subdomain), 8) == 0);
int starts_with_zero_byte = subdomain.preload_int(8) == 0;
if (starts_with_zero_byte & (slice_bits(subdomain) == 8)) { ;; "." requested
return (8, null()); ;; resolved but no dns-records
return (8, null()); ;; resolved but no dns-records
}
if (starts_with_zero_byte) {
subdomain~load_uint(8);

110
contracts/nft-item.fc

@ -3,7 +3,13 @@
#include "imports/op-codes.fc";
#include "imports/params.fc";
int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
int min_tons_for_storage() asm "500000000 PUSHINT"; ;; 0.5 TON
;; sha256('uri')
const uri_key = 51065135818459385347574250312853146822620586594996463797054414300406918686668;
const name_key = 59089242681608890680090686026688704441792375738894456860693970539822503415433;
const image_key = 43884663033947008978309661017057008345326326811558777475113826163084742639165;
const description_key = 90922719342317012409671596374183159143637506542604000676488204638996496437508;
;;
;; === Storage ===
@ -12,26 +18,28 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
;; MsgAddressInt collection_address
;; MsgAddressInt owner_address
;; cell content
;; cell uri
;; cell domain - e.g contains "alice" (without ending \0) for "alice.ton" domain
;; int last_fill_up_time
(int, int, slice, slice, cell, cell, int) load_data() {
(int, int, slice, slice, cell, cell, cell, int) load_data() {
slice ds = get_data().begin_parse();
var (index, collection_address) = (ds~load_uint(256), ds~load_msg_addr());
if (ds.slice_bits() > 0) {
return (-1, index, collection_address, ds~load_msg_addr(), ds~load_ref(), ds~load_ref(), ds~load_uint(64));
return (-1, index, collection_address, ds~load_msg_addr(), ds~load_ref(), ds~load_ref(), ds~load_ref(), ds~load_uint(64));
} else {
return (0, index, collection_address, null(), null(), null(), 0); ;; nft not initialized yet
return (0, index, collection_address, null(), null(), null(), null(), 0); ;; nft not initialized yet
}
}
() store_data(int index, slice collection_address, slice owner_address, cell content, cell domain, int last_fill_up_time) impure {
() store_data(int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) impure {
set_data(
begin_cell()
.store_uint(index, 256)
.store_slice(collection_address)
.store_slice(owner_address)
.store_ref(content)
.store_ref(uri)
.store_ref(domain)
.store_uint(last_fill_up_time, 64)
.end_cell()
@ -54,7 +62,7 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
send_raw_message(msg.end_cell(), send_mode);
}
() transfer_ownership(int my_balance, int index, slice collection_address, slice owner_address, cell content, slice sender_address, int query_id, slice in_msg_body, int fwd_fees, cell domain) impure inline {
() transfer_ownership(int my_balance, int index, slice collection_address, slice owner_address, cell content, cell uri, slice sender_address, int query_id, slice in_msg_body, int fwd_fees, cell domain) impure inline {
slice new_owner_address = in_msg_body~load_msg_addr();
force_chain(new_owner_address);
slice response_destination = in_msg_body~load_msg_addr();
@ -80,7 +88,7 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
send_msg(response_destination, rest_amount, op::excesses(), query_id, null(), 1); ;; paying fees, revert on errors
}
store_data(index, collection_address, new_owner_address, content, domain, now());
store_data(index, collection_address, new_owner_address, content, uri, domain, now());
}
() recv_internal(int msg_value, cell in_msg_full, slice in_msg_body) impure {
@ -99,14 +107,27 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
cs~load_coins(); ;; skip ihr_fee
int fwd_fee = cs~load_coins(); ;; we use message fwd_fee for estimation of forward_payload costs
(int init?, int index, slice collection_address, slice owner_address, cell content, cell domain, int last_fill_up_time) = load_data();
(int init?, int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) = load_data();
if (~ init?) {
throw_unless(405, equal_slices(collection_address, sender_address));
slice from_address = in_msg_body~load_msg_addr();
cell domain = in_msg_body~load_ref();
cell content = begin_cell().store_uint(0, 8).store_dict(new_dict()).end_cell();
store_data(index, collection_address, from_address, content, domain, now());
slice attachment = in_msg_body~load_ref().begin_parse();
cell uri = attachment~load_ref();
cell img_uri = attachment~load_ref();
cell name = attachment~load_ref();
cell description = attachment~load_ref();
cell content_dict = new_dict();
;; content_dict~udict_set_ref(256, uri_key, uri);
content_dict~udict_set_ref(256, image_key, img_uri);
content_dict~udict_set_ref(256, name_key, name);
content_dict~udict_set_ref(256, description_key, description);
cell content = begin_cell().store_uint(0, 8).store_dict(content_dict).end_cell();
store_data(index, collection_address, from_address, content, uri, domain, now());
int rest_amount = msg_value - fwd_fee - min_tons_for_storage();
if (rest_amount > 0) {
send_msg(collection_address, rest_amount, op::excesses(), 0, null(), 1); ;; paying fees, revert on errors
}
return ();
}
@ -119,52 +140,22 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
int op = in_msg_body.slice_empty?() ? 0 : in_msg_body~load_uint(32);
if (op == 0) { ;; todo
;; if (auction_complete) {
;; throw_unless(406, equal_slices(sender_address, owner_address)); ;; only owner can fill-up balance, prevent coins lost right after the auction
;; ;; if owner send bid right after auction he can restore it by transfer resonse message
store_data(index, collection_address, owner_address, content, domain, now());
;; } else {
;; throw_unless(407, msg_value >= muldiv(max_bid_amount, 105, 100)); ;; 5% greater then previous bid
;; int amount_to_send = (max_bid_amount > my_balance - min_tons_for_storage()) ? (my_balance - min_tons_for_storage()) : max_bid_amount;
;; if (amount_to_send > 0) {
;; send_msg(max_bid_address, amount_to_send, op::outbid_notification, cur_lt(), null(), 1); ;; pay transfer fees separately
;; }
;; max_bid_amount = msg_value;
;; max_bid_address = sender_address;
;; int delta_time = auction_prolongation - (auction_end_time - now());
;; if (delta_time > 0) {
;; auction_end_time += delta_time;
;; }
;; store_data(index, collection_address, owner_address, content, domain, now());
;; }
if (op == 0) {
store_data(index, collection_address, owner_address, content, uri, domain, now());
return ();
}
int query_id = in_msg_body~load_uint(64);
;; if ((auction_complete) & (~ cell_null?(auction))) { ;; take domain after auction ;; todo
;; int balance_without_msg = my_balance - msg_value;
;; int amount_to_send = (max_bid_amount > balance_without_msg - min_tons_for_storage()) ? (balance_without_msg - min_tons_for_storage()) : max_bid_amount;
;; if (amount_to_send > 0) {
;; send_msg(collection_address, amount_to_send, op::fill_up, query_id, null(), 2); ;; ignore errors
;; my_balance -= amount_to_send;
;; }
;; owner_address = max_bid_address;
;; auction = null();
;; store_data(index, collection_address, owner_address, content, domain, last_fill_up_time);
;; }
if (op == op::transfer()) {
throw_unless(401, equal_slices(sender_address, owner_address));
transfer_ownership(my_balance, index, collection_address, owner_address, content, sender_address, query_id, in_msg_body, fwd_fee, domain);
transfer_ownership(my_balance, index, collection_address, owner_address, content, uri, sender_address, query_id, in_msg_body, fwd_fee, domain);
return ();
}
if (op == op::edit_content()) { ;; owner can change content and dns records
throw_unless(410, equal_slices(sender_address, owner_address));
store_data(index, collection_address, owner_address, in_msg_body~load_ref(), domain, now());
store_data(index, collection_address, owner_address, in_msg_body~load_ref(), in_msg_body~load_ref(), domain, now());
return ();
}
if (op == op::change_dns_record) { ;; change dns record
@ -186,7 +177,7 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
content = begin_cell().store_uint(0, 8).store_dict(keyvalue_map).end_cell();
store_data(index, collection_address, owner_address, content, domain, now());
store_data(index, collection_address, owner_address, content, uri, domain, now());
return ();
}
if (op == op::process_governance_decision) { ;; governance
@ -197,26 +188,13 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
int config_op = config_value~load_uint(8);
throw_unless(416, (config_op == 0) | (config_op == 1));
if (config_op == 0) { ;; transfer
transfer_ownership(my_balance, index, collection_address, owner_address, content, sender_address, query_id, config_value, fwd_fee, domain);
transfer_ownership(my_balance, index, collection_address, owner_address, content, uri, sender_address, query_id, config_value, fwd_fee, domain);
}
if (config_op == 1) { ;; destroy
send_msg(collection_address, 0, op::fill_up, query_id, null(), 128 + 32); ;; carry all the remaining balance + destroy
}
return ();
}
if (op == op::dns_balance_release) { ;; release domain
throw_unless(414, (now() - last_fill_up_time > one_year));
int min_price = get_min_price(domain.begin_parse().slice_bits(), now());
throw_unless(407, msg_value >= min_price);
int balance_without_msg = my_balance - msg_value;
int amount_to_send = balance_without_msg - min_tons_for_storage();
if (amount_to_send > 0) {
send_msg(owner_address, amount_to_send, op::dns_balance_release, query_id, null(), 2); ;; ignore errors
}
owner_address = zero_address();
store_data(index, collection_address, owner_address, content, domain, now());
return ();
}
if (op == op::get_static_data()) {
send_msg(sender_address, 0, op::report_static_data(), query_id, begin_cell().store_uint(index, 256).store_slice(collection_address), 64); ;; carry all the remaining value of the inbound message
return ();
@ -229,22 +207,22 @@ int min_tons_for_storage() asm "1000000000 PUSHINT"; ;; 1 TON
;;
(int, int, slice, slice, cell) get_nft_data() method_id {
(int init?, int index, slice collection_address, slice owner_address, cell content, cell domain, int last_fill_up_time) = load_data();
return (init?, index, collection_address, owner_address, content);
(int init?, int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) = load_data();
return (init?, index, collection_address, owner_address, uri);
}
slice get_editor() method_id {
(int init?, int index, slice collection_address, slice owner_address, cell content, cell domain, int last_fill_up_time) = load_data();
(int init?, int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) = load_data();
return owner_address;
}
slice get_domain() method_id {
(int init?, int index, slice collection_address, slice owner_address, cell content, cell domain, int last_fill_up_time) = load_data();
(int init?, int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) = load_data();
return domain.begin_parse();
}
int get_last_fill_up_time() method_id {
(int init?, int index, slice collection_address, slice owner_address, cell content, cell domain, int last_fill_up_time) = load_data();
(int init?, int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) = load_data();
return last_fill_up_time;
}
@ -253,7 +231,7 @@ int get_last_fill_up_time() method_id {
throw_unless(70, mod(subdomain_bits, 8) == 0);
(int init?, int index, slice collection_address, slice owner_address, cell content, cell my_domain_cell, int last_fill_up_time) = load_data();
(int init?, int index, slice collection_address, slice owner_address, cell content, cell uri, cell domain, int last_fill_up_time) = load_data();
slice cs = content.begin_parse();
throw_unless(412, cs~load_uint(8) == 0); ;; data onchain tag

165
contracts/utils.ts

@ -1,11 +1,14 @@
import {Cell} from "ton";
import {beginCell, beginDict, BitString, Cell, DictBuilder, TonClient} from "ton";
import {sha256} from "ton-crypto";
import {BN} from "bn.js";
// from https://github.com/getgems-io/nft-contracts/blob/main/packages/nft-content/nftContent.ts
const OFF_CHAIN_CONTENT_PREFIX = 0x01
const ON_CHAIN_CONTENT_PREFIX = 0x00
export function flattenSnakeCell(cell: Cell) {
let c: Cell|null = cell
let c: Cell | null = cell
let res = Buffer.alloc(0)
@ -55,12 +58,162 @@ export function encodeOffChainContent(content: string) {
return makeSnakeCell(data)
}
export async function encodeSemiChainContent(uri: string) {
let db = beginDict(256);
db.storeCell(await sha256("uri"), beginCell().storeBuffer(Buffer.from(uri)).endCell());
let data = db.endDict()?.toBoc() as Buffer;
let offChainPrefix = Buffer.from([ON_CHAIN_CONTENT_PREFIX])
data = Buffer.concat([offChainPrefix, data])
return makeSnakeCell(data)
}
export function decodeOffChainContent(content: Cell) {
let data = flattenSnakeCell(content)
let prefix = data[0]
if (prefix !== OFF_CHAIN_CONTENT_PREFIX) {
throw new Error(`Unknown content prefix: ${prefix.toString(16)}`)
}
// let prefix = data[0]
// if (prefix !== OFF_CHAIN_CONTENT_PREFIX) {
// throw new Error(`Unknown content prefix: ${prefix.toString(16)}`)
// }
return data.slice(1).toString()
}
export function get_tonclient(isTestnet: boolean) {
return new TonClient({
endpoint: `https://${isTestnet ? "testnet." : ""}toncenter.com/api/v2/jsonRPC`,
apiKey: isTestnet ? 'bed2b4589201ff3c575be653593f912a337c08eed416b60b02345763b9ee9c36' : 'a1e8a1055a387515158589dc7e9bad3035e7db2b9f9ea5cdad6b727f71e328db'
});
}
// look up tables
const to_hex_array: string[] = [];
const to_byte_map: any = {};
for (let ord = 0; ord <= 0xff; ord++) {
let s = ord.toString(16);
if (s.length < 2) {
s = "0" + s;
}
to_hex_array.push(s);
to_byte_map[s] = ord;
}
/**
* @param buffer {Uint8Array}
* @return {string}
*/
function bytesToHex(buffer: Uint8Array) {
const hex_array = [];
//(new Uint8Array(buffer)).forEach((v) => { hex_array.push(to_hex_array[v]) });
for (let i = 0; i < buffer.byteLength; i++) {
hex_array.push(to_hex_array[buffer[i]]);
}
return hex_array.join("");
}
// reverse conversion using lookups
/**
* @param s {string}
* @return {Uint8Array}
*/
function hexToBytes(s: string) {
s = s.toLowerCase();
const length2 = s.length;
if (length2 % 2 !== 0) {
throw "hex string must have length a multiple of 2";
}
const length = length2 / 2;
const result = new Uint8Array(length);
for (let i = 0; i < length; i++) {
const i2 = i * 2;
const b = s.substring(i2, i2 + 2);
if (!to_byte_map.hasOwnProperty(b)) throw new Error('invalid hex character ' + b);
result[i] = to_byte_map[b];
}
return result;
}
export class AdnlAddress {
bytes: Uint8Array;
/**
* @param anyForm {string | Uint8Array | AdnlAddress}
*/
constructor(anyForm: AdnlAddress | string | Uint8Array | null) {
if (anyForm == null) {
throw "Invalid address";
}
if (anyForm instanceof AdnlAddress) {
this.bytes = anyForm.bytes;
} else if (anyForm instanceof Uint8Array) {
if (anyForm.length !== 32) {
throw new Error('invalid adnl bytes length');
}
this.bytes = anyForm;
} else if (typeof anyForm === 'string') {
if (anyForm.length !== 64) {
throw new Error('invalid adnl hex length');
}
this.bytes = hexToBytes(anyForm);
} else {
throw new Error('unsupported type')
}
}
toHex() {
let hex = bytesToHex(this.bytes);
while (hex.length < 64) {
hex = '0' + hex;
}
return hex;
}
}
export async function categoryToBN(category: string) {
if (!category) return new BN(0); // all categories
const categoryHash = await sha256(category);
return new BN(categoryHash);
}
const base64abc = (() => {
const abc = []
const A = "A".charCodeAt(0);
const a = "a".charCodeAt(0);
const n = "0".charCodeAt(0);
for (let i = 0; i < 26; ++i) {
abc.push(String.fromCharCode(A + i));
}
for (let i = 0; i < 26; ++i) {
abc.push(String.fromCharCode(a + i));
}
for (let i = 0; i < 10; ++i) {
abc.push(String.fromCharCode(n + i));
}
abc.push("+");
abc.push("/");
return abc;
})();
export function bytesToBase64(bytes: Buffer) {
let result = "";
let i;
const l = bytes.length;
for (i = 2; i < l; i += 3) {
result += base64abc[bytes[i - 2] >> 2];
result += base64abc[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)];
result += base64abc[((bytes[i - 1] & 0x0f) << 2) | (bytes[i] >> 6)];
result += base64abc[bytes[i] & 0x3f];
}
if (i === l + 1) {
// 1 octet missing
result += base64abc[bytes[i - 2] >> 2];
result += base64abc[(bytes[i - 2] & 0x03) << 4];
result += "==";
}
if (i === l) {
// 2 octets missing
result += base64abc[bytes[i - 2] >> 2];
result += base64abc[((bytes[i - 2] & 0x03) << 4) | (bytes[i - 1] >> 4)];
result += base64abc[(bytes[i - 1] & 0x0f) << 2];
result += "=";
}
return result;
}

1501
package-lock.json generated

File diff suppressed because it is too large Load Diff

14
package.json

@ -10,11 +10,13 @@
"build": "ts-node ./build/_build.ts",
"deploy": "ts-node ./build/_deploy.ts",
"deploy:testnet": "ts-node ./build/_deploy.ts",
"postinstall": "ts-node ./build/_setup.ts"
"postinstall_": "ts-node build/_setup.ts",
"cli": "node --no-warnings --loader ts-node/esm bin/cli.js",
"api": "node --no-warnings --loader ts-node/esm bin/api.js "
},
"devDependencies": {
"@swc/core": "^1.2.177",
"@types/bn.js": "^5.1.0",
"@swc/core": "^1.3.25",
"@types/bn.js": "^5.1.1",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"@types/semver": "^7.3.9",
@ -46,6 +48,10 @@
"node": ">=16.15.0"
},
"dependencies": {
"semver": "^7.3.7"
"@tonconnect/protocol": "^2.0.1",
"semver": "^7.3.7",
"subcommand": "^2.1.1",
"ton-compiler": "^2.0.0",
"express": "^4.18.2"
}
}

19
test/creation.spec.ts

@ -9,6 +9,7 @@ import * as main from "../contracts/main";
import { internalMessage, randomAddress } from "./helpers";
import { hex } from "../build/nft-collection.compiled.json";
import {hex as item_code} from "../build/nft-item.compiled.json";
import {makeSnakeCell} from "../contracts/utils";
describe("Creating items tests", () => {
@ -20,7 +21,7 @@ describe("Creating items tests", () => {
Cell.fromBoc(hex)[0],
main.collectionData({
ownerAddress: randomAddress("owner"),
code: Cell.fromBoc(hex)[0],
code: Cell.fromBoc(item_code)[0],
ownerKey: 0,
}),
{ debug: debug }
@ -33,13 +34,23 @@ describe("Creating items tests", () => {
const sendToSelfMessage = internalMessage({
from: ownerAddr,
body: main.createItem({ domain: "test" }),
value: new BN(10 * main.TON()),
value: new BN(100 * main.TON()),
});
const res = await contract.sendInternalMessage(sendToSelfMessage);
console.log(res);
expect(res.type).to.equal("success");
expect(res.exit_code).to.equal(0);
});
it("does not allow to buy an item if the price is too low", async () => {
main.setContractBalance(contract, 10 * main.TON());
let ownerAddr = randomAddress("owner");
const sendToSelfMessage = internalMessage({
from: ownerAddr,
body: main.createItem({ domain: "test" }),
value: new BN(main.TON() / 100),
});
const res = await contract.sendInternalMessage(sendToSelfMessage);
expect(res.type).to.equal("failed");
});
});

71
test/item.spec.ts

@ -0,0 +1,71 @@
import chai, {assert, expect} from "chai";
import chaiBN from "chai-bn";
import BN from "bn.js";
chai.use(chaiBN(BN));
import {Address, beginCell, Builder, Cell, contractAddress, parseDict, parseDictBitString, Slice, toNano} from "ton";
import {runContract, SmartContract} from "ton-contract-executor";
import * as main from "../contracts/main";
import {internalMessage, randomAddress} from "./helpers";
import {hex as item_code} from "../build/nft-item.compiled.json";
import {makeSnakeCell} from "../contracts/utils";
import {keyPairFromSeed, KeyPair, sign, keyPairFromSecretKey, sha256} from "ton-crypto";
import {signBuy} from "../contracts/main";
import {Base64} from "@tonconnect/protocol";
let data = main.itemDataUninit({domain: "test", collectionAddress: randomAddress("collection")});
describe("Creating item tests", () => {
let contract: SmartContract;
let debug: boolean = true;
beforeEach(async () => {
contract = await SmartContract.fromCell(
Cell.fromBoc(item_code)[0],
data,
{debug: debug}
);
contract.setC7Config({
myself: randomAddress("item"),
balance: toNano(1).toNumber(),
})
});
it("allows to set the data", async () => {
let ownerAddr = randomAddress("dude");
const initializeMsg = internalMessage({
from: randomAddress("collection"),
body: main.initializeItemMsg({domain: "levcccc", ownerAddr, zone: "example.ton"}),
value: new BN(0),
});
const res = await contract.sendInternalMessage(initializeMsg);
// let nft_data = await contract.invokeGetMethod("get_nft_data", []);
// console.log(nft_data.result);
expect(res.type).to.equal("success");
expect(res.exit_code).to.equal(0);
const setDataMsg = internalMessage({
from: ownerAddr,
body: await main.setContent({domain: "levcccc", zone: "example.ton"}),
value: new BN(toNano(2)),
})
const res2 = await contract.sendInternalMessage(setDataMsg);
expect(res2.type).to.equal("success");
expect(res2.exit_code).to.equal(0);
let nft_data = await contract.invokeGetMethod("get_nft_data", []);
console.log('res4', nft_data.result[4]);
// @ts-ignore
console.log(Base64.encode((nft_data.result[4] as Cell).toBoc()))
// @ts-ignore
// let content = (nft_data.result[4] as Cell).beginParse();
// let a = parseDict(content, 256, (s) => s);
// console.log(a);
let resolved = (await contract.invokeGetMethod("dnsresolve", [
{type: "cell_slice", value: "te6cckEBAQEAAwAAAgDTZ9xB"},
{type: "int", value: new BN(await sha256('uri')).toString()}
]));
expect(resolved.type).to.equal("success");
});
});

56
test/selling.spec.ts

@ -1,56 +0,0 @@
import chai, { assert, expect } from "chai";
import chaiBN from "chai-bn";
import BN from "bn.js";
chai.use(chaiBN(BN));
import { Builder, Cell, Slice } from "ton";
import { SmartContract } from "ton-contract-executor";
import * as main from "../contracts/main";
import { internalMessage, randomAddress } from "./helpers";
import { hex } from "../build/main.compiled.json";
import { makeSnakeCell } from "../contracts/utils";
import { signVerify } from "ton-crypto";
describe("Selling tests (instant buy)", () => {
let contract: SmartContract;
let debug: boolean = true;
let keyPair = main.genKeyPair();
beforeEach(async () => {
contract = await SmartContract.fromCell(
Cell.fromBoc(hex)[0],
main.data({
ownerAddress: randomAddress("owner"),
code: Cell.fromBoc(hex)[0],
collectionAddress: randomAddress("collection"),
domain: "alice",
publicKey: keyPair.publicKey
}),
{ debug: debug }
);
});
it("Sell", async () => {
main.setContractBalance(contract, 10 * main.TON());
const sellMessage = internalMessage({
from: randomAddress("buyer"),
body: main.instantBuyMessage({
receiverAddress: randomAddress("buyer"),
issuedCollectionAddr: randomAddress("collection"),
price: 10 * main.TON(),
domain: "bob",
privateKey: keyPair.secretKey
}),
value: new BN(10 * main.TON())
});
context("Public key is correct", async () => {
const pubKeyRes = await contract.invokeGetMethod("get_public_key", []);
expect(pubKeyRes.result[0]).to.equal(keyPair.publicKey);
});
const res = await contract.sendInternalMessage(sellMessage);
expect(res.type).to.equal("success");
expect(res.exit_code).to.equal(0);
});
});

71
test/signing.spec.ts

@ -0,0 +1,71 @@
import chai, {assert, expect} from "chai";
import chaiBN from "chai-bn";
import BN from "bn.js";
chai.use(chaiBN(BN));
import {Address, Builder, Cell, contractAddress, Slice} from "ton";
import {runContract, SmartContract} from "ton-contract-executor";
import * as main from "../contracts/main";
import {internalMessage, randomAddress} from "./helpers";
import {hex} from "../build/nft-collection.compiled.json";
import {hex as item_code} from "../build/nft-item.compiled.json";
import {makeSnakeCell} from "../contracts/utils";
import {keyPairFromSeed, KeyPair, sign, keyPairFromSecretKey} from "ton-crypto";
import {signBuy} from "../contracts/main";
let ownerKeys = keyPairFromSeed(Buffer.from("0000000000000000000000000000000000000000000000000000000000000000", "hex"));
let ownerPubNum = new BN(ownerKeys.publicKey);
let data = main.collectionData({
ownerAddress: randomAddress("owner"),
code: Cell.fromBoc(item_code)[0],
ownerKey: ownerPubNum,
});
describe("Signing tests", () => {
let contract: SmartContract;
let debug: boolean = true;
beforeEach(async () => {
contract = await SmartContract.fromCell(
Cell.fromBoc(hex)[0],
data,
{debug: debug}
);
contract.setC7Config({
myself: randomAddress("collection")
})
});
it("allows to buy an item with a valid signature", async () => {
main.setContractBalance(contract, 10 * main.TON(), randomAddress("collection"));
let ownerAddr = randomAddress("dude");
let signature = signBuy("test", randomAddress("collection"), ownerAddr, ownerKeys.secretKey);
const sendToSelfMessage = internalMessage({
from: ownerAddr,
body: main.createItem({domain: "test", signature: signature}),
value: new BN(100 * main.TON()),
});
const res = await contract.sendInternalMessage(sendToSelfMessage);
// console.log(res);
// let fs = require('fs');
// fs.writeFile('logs.txt', res.logs, (_: any) => {});
expect(res.type).to.equal("success");
expect(res.exit_code).to.equal(0);
});
it("does not allow to buy an item if the signature is for another user", async () => {
main.setContractBalance(contract, 10 * main.TON(), randomAddress("collection"));
let signature = signBuy("test", randomAddress("collection"), randomAddress("dude"), ownerKeys.secretKey);
const sendToSelfMessage = internalMessage({
from: randomAddress("dude2"),
body: main.createItem({domain: "test", signature: signature}),
value: new BN(100 * main.TON()),
});
const res = await contract.sendInternalMessage(sendToSelfMessage);
expect(res.type).to.equal("failed");
expect(res.exit_code).to.equal(205);
});
});
Loading…
Cancel
Save