LibStrings
Address
0x4ab87f1DBDF6f741ED8BF481C7346103a86f1068Code
[
{
"inputs": [
{
"internalType": "address",
"name": "VoidAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
},
{
"internalType": "uint256",
"name": "allowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "DysnomiaInsufficientAllowance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "DysnomiaInsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "MarketRateNotFound",
"type": "error"
},
{
"inputs": [],
"name": "MinimumLength3",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
}
],
"name": "OwnableInvalidOwner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
}
],
"name": "OwnableUnauthorizedAccount",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "bool",
"name": "state",
"type": "bool"
}
],
"name": "OwnershipUpdate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "bytes1",
"name": "A",
"type": "bytes1"
},
{
"internalType": "bytes1",
"name": "B",
"type": "bytes1"
}
],
"name": "CaseInsensitiveCompare",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_A",
"type": "string"
},
{
"internalType": "string",
"name": "_B",
"type": "string"
}
],
"name": "CheckAcronym",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_acronym",
"type": "bytes"
},
{
"internalType": "string",
"name": "_Beta",
"type": "string"
}
],
"name": "CheckAcronym",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "S",
"type": "string"
}
],
"name": "CheckPalindrome",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "S",
"type": "bytes"
}
],
"name": "CheckPalindrome",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_a",
"type": "address"
}
],
"name": "GetMarketRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "value",
"type": "bytes32"
}
],
"name": "Hex",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Hex",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "Hex",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "Hex",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "MotzkinPrime",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_t",
"type": "address"
},
{
"internalType": "uint256",
"name": "_a",
"type": "uint256"
}
],
"name": "Purchase",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint8",
"name": "MaxLength",
"type": "uint8"
}
],
"name": "RandomAcronym",
"outputs": [
{
"internalType": "bytes",
"name": "Acronym",
"type": "bytes"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_t",
"type": "address"
},
{
"internalType": "uint256",
"name": "_a",
"type": "uint256"
}
],
"name": "Redeem",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "newName",
"type": "string"
},
{
"internalType": "string",
"name": "newSymbol",
"type": "string"
}
],
"name": "Rename",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "S",
"type": "bytes"
}
],
"name": "Reverse",
"outputs": [
{
"internalType": "bytes",
"name": "Reversed",
"type": "bytes"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "S",
"type": "string"
}
],
"name": "Reverse",
"outputs": [
{
"internalType": "string",
"name": "Reversed",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "String",
"outputs": [
{
"internalType": "string",
"name": "buffer",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "Type",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "Xiao",
"outputs": [
{
"internalType": "contract atropaMath",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "addOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "log10",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "maxSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "mintToCap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "cOwner",
"type": "address"
}
],
"name": "owner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "toRemove",
"type": "address"
}
],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]// SPDX-License-Identifier: Sharia
pragma solidity ^0.8.21;
import "../01_dysnomia_v2.sol";
contract STRINGLIB is DYSNOMIA {
string public constant Type = "LibStrings";
constructor(address VoidAddress) DYSNOMIA(unicode"DYSNOMIA LibStrings", unicode"LibStrings", address(DYSNOMIA(VoidAddress).Xiao())) {
VOID Void = VOID(VoidAddress);
addOwner(VoidAddress);
addOwner(tx.origin);
Void.AddLibrary("strings", address(this));
_addMarketRate(AFFECTIONContract, 1 * 10 ** decimals());
_mintToCap();
}
function CheckPalindrome(string memory S) public pure returns(bool) {
return CheckPalindrome(bytes(S));
}
function CheckPalindrome(bytes memory S) public pure returns(bool) {
bytes memory Reversed = Reverse(S);
uint256 j = S.length;
uint256 i = 0;
while (i < S.length)
if (Reversed[--j] != S[i++]) return false;
return true;
}
function Reverse(string memory S) public pure returns(string memory Reversed) {
return string(Reverse(bytes(S)));
}
function Reverse(bytes memory S) public pure returns(bytes memory Reversed) {
Reversed = new bytes(S.length);
uint256 j = S.length;
uint256 i = 0;
while (i < S.length)
Reversed[--j] = S[i++];
}
error MinimumLength3();
function RandomAcronym(uint8 MaxLength) public returns(bytes memory Acronym) {
if(MaxLength < 3) revert MinimumLength3();
bytes memory LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
uint64 length = 2 + (Xiao.Random() % (MaxLength - 2));
Acronym = new bytes(length);
for(uint i = 0; i < length; i++) {
uint64 nxtchar = Xiao.Random() % 26;
Acronym[i] = LETTERS[nxtchar];
}
_mintToCap();
}
function CaseInsensitiveCompare(bytes1 A, bytes1 B) public pure returns (bool) {
if(uint8(B) <= 90)
return(A == B || uint8(A) == (uint8(B) + 32));
else
return(A == B || (uint8(A) + 32) == uint8(B));
}
function CheckAcronym(string memory _A, string memory _B) public pure returns(bool) {
return CheckAcronym(bytes(_A), _B);
}
function CheckAcronym(bytes memory _acronym, string memory _Beta) public pure returns(bool) {
bytes memory Beta = bytes(_Beta);
if(_acronym.length == 0 || Beta.length == 0) return false;
if(!CaseInsensitiveCompare(Beta[0], _acronym[0])) return false;
uint8 _pos = 1;
for(uint256 i = 1; i < Beta.length; i++) {
if(uint8(Beta[i]) == 32) {
if(_pos >= _acronym.length) return false;
if(!CaseInsensitiveCompare(Beta[i+1], _acronym[_pos])) return false;
else {
_pos = _pos + 1;
i = i + 1;
}
}
if(_pos > _acronym.length) return false;
}
if(_pos != _acronym.length) return false;
return true;
}
function log10(uint256 value) public pure returns (uint256) {
uint256 result = 0;
unchecked {
for(uint8 _e = 64; _e >= 1; _e /= 2) {
if (value >= 10 ** _e) {
value /= 10 ** _e;
result += _e;
}
}
}
return result;
}
function String(uint256 value) public pure returns (string memory buffer) {
unchecked {
uint256 length = log10(value) + 1;
buffer = new string(length);
uint256 ptr;
assembly { ptr := add(buffer, add(32, length)) }
while (true) {
ptr--;
assembly { mstore8(ptr, byte(mod(value, 10), "0123456789abcdef")) }
value /= 10;
if (value == 0) break;
}
}
}
function Hex(address account) public pure returns(string memory) {
return Hex(abi.encodePacked(account));
}
function Hex(uint256 value) public pure returns(string memory) {
return Hex(abi.encodePacked(value));
}
function Hex(bytes32 value) public pure returns(string memory) {
return Hex(abi.encodePacked(value));
}
function Hex(bytes memory data) public pure returns(string memory) {
bytes memory hexa = "0123456789abcdef";
bytes memory str = new bytes(2 + data.length * 2);
str[0] = "0";
str[1] = "x";
for (uint i = 0; i < data.length; i++) {
str[2+i*2] = hexa[uint(uint8(data[i] >> 4))];
str[3+i*2] = hexa[uint(uint8(data[i] & 0x0f))];
}
return string(str);
}
}Last updated